mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
30 lines
955 B
SQL
30 lines
955 B
SQL
DROP TABLE IF EXISTS default_constraints;
|
|
CREATE TABLE default_constraints
|
|
(
|
|
x UInt8,
|
|
y UInt8 DEFAULT x + 1,
|
|
CONSTRAINT c CHECK y < 5
|
|
) ENGINE = Memory;
|
|
|
|
INSERT INTO default_constraints (x) SELECT number FROM system.numbers LIMIT 5; -- { serverError VIOLATED_CONSTRAINT }
|
|
INSERT INTO default_constraints (x) VALUES (0),(1),(2),(3),(4); -- { serverError VIOLATED_CONSTRAINT }
|
|
|
|
SELECT y, throwIf(NOT y < 5) FROM default_constraints;
|
|
SELECT count() FROM default_constraints;
|
|
|
|
DROP TABLE default_constraints;
|
|
|
|
|
|
CREATE TEMPORARY TABLE default_constraints
|
|
(
|
|
x UInt8,
|
|
y UInt8 DEFAULT x + 1,
|
|
CONSTRAINT c CHECK y < 5
|
|
);
|
|
|
|
INSERT INTO default_constraints (x) SELECT number FROM system.numbers LIMIT 5; -- { serverError VIOLATED_CONSTRAINT }
|
|
INSERT INTO default_constraints (x) VALUES (0),(1),(2),(3),(4); -- { serverError VIOLATED_CONSTRAINT }
|
|
|
|
SELECT y, throwIf(NOT y < 5) FROM default_constraints;
|
|
SELECT count() FROM default_constraints;
|