2020-07-14 21:02:41 +00:00
|
|
|
---
|
2022-08-28 14:53:34 +00:00
|
|
|
slug: /en/sql-reference/statements/alter/constraint
|
2022-04-09 13:29:05 +00:00
|
|
|
sidebar_position: 43
|
|
|
|
sidebar_label: CONSTRAINT
|
2020-07-14 21:02:41 +00:00
|
|
|
---
|
|
|
|
|
2022-06-02 10:55:18 +00:00
|
|
|
# Manipulating Constraints
|
2020-07-14 21:02:41 +00:00
|
|
|
|
|
|
|
Constraints could be added or deleted using following syntax:
|
|
|
|
|
|
|
|
``` sql
|
2022-09-01 11:31:22 +00:00
|
|
|
ALTER TABLE [db].name [ON CLUSTER cluster] ADD CONSTRAINT constraint_name CHECK expression;
|
|
|
|
ALTER TABLE [db].name [ON CLUSTER cluster] DROP CONSTRAINT constraint_name;
|
2020-07-14 21:02:41 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
See more on [constraints](../../../sql-reference/statements/create/table.md#constraints).
|
|
|
|
|
|
|
|
Queries will add or remove metadata about constraints from table so they are processed immediately.
|
|
|
|
|
2023-03-27 18:54:05 +00:00
|
|
|
:::tip
|
2022-04-09 13:29:05 +00:00
|
|
|
Constraint check **will not be executed** on existing data if it was added.
|
|
|
|
:::
|
2020-07-14 21:02:41 +00:00
|
|
|
|
|
|
|
All changes on replicated tables are broadcasted to ZooKeeper and will be applied on other replicas as well.
|