ALTER TABLE command. When you change the
schema, the changes are also propagated to each underlying .
While you can change the schema of an existing , you cannot change the schema of a . For s,
the only permissible changes are renaming a view, setting a schema, changing the owner, and adjusting other
parameters.
address to a table called distributors:
NULL for the new column.
Changing the schema can, in some cases, consume a lot of resources. This is especially true if it requires underlying
data to be rewritten. If you want to check your schema change before you apply it, you can use a CHECK constraint,
like this:
Alter hypertables with columnstore enabled
Most common schema modifications work on s with enabled, including adding columns, renaming columns, dropping columns, adding constraints, setting NOT NULL, and changing defaults. However, some operations are blocked, the most common of them being:- Changing column data type (
ALTER COLUMN ... TYPE) - Changing column storage (
ALTER COLUMN ... SET STORAGE) - Dropping orderby or segmentby columns
- Row-level security operations (
ENABLE/DISABLE ROW SECURITY)
- Stop any policy
- Convert the affected s back into
- Disable
- Perform the schema change
- Re-enable and restart the policy
Change the column type on a hypertable
This example shows how to change a column’s data type on a with enabled, which requires conversion to :-
Create a hypertable with columnstore enabled
-
(Optional) Insert sample data
-
Check for a columnstore policy and note its settings
-
If a policy exists, pause it
-
Convert all chunks back to rowstore
-
Disable columnstore
-
Perform the schema modification
-
Re-enable columnstore with original settings
-
Restart the columnstore policy
-
(Optional) Manually convert the chunks to columnstore immediately
ALTER TABLE operations, see the ALTER TABLE documentation.