The secondary index created by ALTER PRIMARY KEY takes up node memory and can slow down write performance to a cluster. ALTER PRIMARY KEY, the existing primary key index becomes a secondary index. When you change a primary key with ALTER TABLE. Changing primary keys with ADD CONSTRAINT. An unvalidated constraint can later be validated using VALIDATE CONSTRAINT.įor usage, see Synopsis. The constraint is still enforced when table data is modified. When creating an unvalidated constraint, the system does not check that existing table data satisfies the constraint. Adding/changing the table's PRIMARY KEY is not supported through ALTER TABLE it can only be specified during table creation.Ĭreate unvalidated constraints. Adding/changing a DEFAULT constraint is done through ALTER COLUMN. The CHECK, foreign key, or UNIQUE constraint you want to add. The name of the constraint, which must be unique to its table and follow these identifier rules. Required privilegesĪdd a constraint only if a constraint of the same name does not already exist if one does exist, do not return an error. The DEFAULT and NOT NULL constraints are managed through ALTER COLUMN.įor examples, see Add constraints. For details, see Changing primary keys with ADD CONSTRAINT. To replace an existing primary key, you can use ADD CONSTRAINT. To add a primary key constraint to a table, you should explicitly define the primary key at table creation. ADD CONSTRAINT to add the following constraints to columns: The column name must follow these identifier rules and must be unique within the table but can have the same name as indexes or constraints.Īn optional list of column qualifications. Parameters ParameterĪdd a column only if a column of the same name does not already exist if one does exist, do not return an error. The user must have the CREATE privilege on the table. ADD COLUMN to add columns to existing tables.įor examples, see Add columns. Remove a range split enforcement in the table.Ĭheck whether values in a column match a constraint on the column. Set the table locality for a table in a multi-region database.įorce a range split at the specified row in the table. Reset a storage parameter on a table to its default value. Partition, re-partition, or un-partition a table. For example, you can atomically rename a column and add a new column with the old name of the existing column.Įnable per-table audit logs, for security purposes. Some subcommands can be used in combination in a single ALTER TABLE statement. The name of the table you want to change.Īdditional parameters are documented for the respective subcommands. ADD COLUMN IF NOT EXISTS column_name typename col_qualification CONSTRAINT IF NOT EXISTS constraint_name constraint_elem NOT VALID RENAME COLUMN column_name TO column_new_name CONSTRAINT constraint_name TO constraint_new_name ALTER COLUMN column_name SET DEFAULT a_expr ON UPDATE b_expr VISIBLE NOT VISIBLE NULL DROP DEFAULT ON UPDATE NOT NULL STORED SET DATA TYPE typename COLLATE collation_name USING a_expr PRIMARY KEY USING COLUMNS ( index_params ) USING HASH WITH ( storage_parameter_key = value, ) DROP COLUMN IF EXISTS column_name CONSTRAINT IF EXISTS constraint_name CASCADE RESTRICT VALIDATE CONSTRAINT constraint_name EXPERIMENTAL_AUDIT SET READ WRITE OFF PARTITION ALL BY LIST ( name_list ) ( list_partitions RANGE ( name_list ) ( range_partitions ) NOTHING SET ( storage_parameter_key = value, RESET ( storage_parameter_key, ), Parameters ParameterĬhange the table only if a table with the current name exists if one does not exist, do not return an error.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |