

When you alter a sort key to AUTO, Amazon Redshift preserves the existing sort key of the table. ALTER SORTKEY AUTOĪ clause that changes or adds the sort key of the target table to AUTO. Information about SORTKEY, see CREATE TABLE. When you alter the sort key, Amazon Redshift reorders the data. When data is loaded into a table, the data is loaded in the order of the For more information about compression, see Compression encodings The table size increases depend on the specific table definition and This can increase the amount of storage required by the table. The column’s compression is changed to RAW compression (no compression). When you alter a column to choose it as a sort key, If the sort key was previously defined as AUTO, then the table is no longer a candidate for automatic table optimization.Īmazon Redshift recommends using RAW encoding (no compression) for columnsĭefined as sort keys.

However, you can't alter a compound sort key to an interleaved sort key. You can alter an interleaved sort key to a compound You can define a maximum of 400 columns for a sort key per table.

Table, then Amazon Redshift automatically assigns compression encodings as follows: If no encoding is explicitly defined for the

When you alter a sort key, the compression encoding of columns in the new or ALTER SORTKEY ( column_name )Ī clause that changes or adds the sort key used for a table. To view the actions taken by Amazon Redshift, query the SVL_AUTO_WORKER_ACTION system catalog view. To view the Amazon Redshift Advisor recommendations for tables, query the SVV_ALTER_TABLE_RECOMMENDATIONS system catalog view. To view the distribution style of a table, query the SVV_TABLE_INFO system catalog view. See Amazon Redshift Advisor recommendations.įor more information about DISTSTYLE AUTO, see Then Amazon Redshift might change the distribution style or key of your table in the future.įor example, Amazon Redshift might convert a table with a DISTSTYLE of AUTO(KEY) to AUTO(EVEN), or vice versa.įor more information about behavior when distribution keys are altered, including data redistribution and locks, If Amazon Redshift determines that a new distribution style or key will improve the performance of queries, In this case, Amazon Redshift makes no changes to the table. This clause only supports altering the size of a VARCHAR data type.Ī small table with DISTSTYLE ALL is converted to AUTO(ALL).Ī small table with DISTSTYLE EVEN is converted to AUTO(ALL).Ī small table with DISTSTYLE KEY is converted to AUTO(ALL).Ī large table with DISTSTYLE ALL is converted to AUTO(EVEN).Ī large table with DISTSTYLE EVEN is converted to AUTO(EVEN).Ī large table with DISTSTYLE KEY is converted to AUTO(KEY) and the DISTKEY is preserved. ALTER COLUMN column_name TYPEĪ clause that changes the size of a column defined as a VARCHAR data type. Table name beginning with '#' indicates a temporary table. You can't rename a permanent table to a name that begins with '#'. The maximum table name length is 127 bytes OWNER TO new_ownerĪ clause that changes the owner of the table (or view) to theĪ clause that renames a table (or view) to the value specified in CASCADE is an option for DROP CONSTRAINT. CASCADEĪ clause that removes the specified constraint and anything dependent on RESTRICT is an optionįor DROP CONSTRAINT. To reduce the time to run the ALTER TABLE command, you can combine some clauses ofĪmazon Redshift supports the following combinations of the ALTER TABLE clauses:įrom information_schema.table_constraints RESTRICTĪ clause that removes only the specified constraint. | DROP PARTITION ( partition_column= partition_value ) | ALTER DISTSTYLE KEY DISTKEY column_name | ALTER COLUMN column_name ENCODE encode_type. | ALTER COLUMN column_name ENCODE encode_type, | ALTER COLUMN column_name ENCODE new_encode_type | ALTER COLUMN column_name TYPE updated_varchar_data_type_size Table owner with the USAGE privilege on the schema
