2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: no-replicated-database
|
|
|
|
|
2020-05-25 11:11:51 +00:00
|
|
|
DROP TABLE IF EXISTS data_null;
|
2020-05-25 18:58:30 +00:00
|
|
|
DROP TABLE IF EXISTS set_null;
|
2021-04-16 10:15:35 +00:00
|
|
|
DROP TABLE IF EXISTS cannot_be_nullable;
|
2020-05-25 11:11:51 +00:00
|
|
|
|
2020-06-14 16:17:22 +00:00
|
|
|
SET data_type_default_nullable='false';
|
|
|
|
|
2020-05-25 11:11:51 +00:00
|
|
|
CREATE TABLE data_null (
|
|
|
|
a INT NULL,
|
|
|
|
b INT NOT NULL,
|
2020-05-25 18:58:30 +00:00
|
|
|
c Nullable(INT),
|
|
|
|
d INT
|
|
|
|
) engine=Memory();
|
2020-05-25 11:11:51 +00:00
|
|
|
|
|
|
|
|
2020-06-14 16:17:22 +00:00
|
|
|
INSERT INTO data_null VALUES (NULL, 2, NULL, 4);
|
2020-05-25 18:58:30 +00:00
|
|
|
|
|
|
|
SELECT toTypeName(a), toTypeName(b), toTypeName(c), toTypeName(d) FROM data_null;
|
|
|
|
|
2020-06-14 16:17:22 +00:00
|
|
|
SHOW CREATE TABLE data_null;
|
2020-05-25 18:58:30 +00:00
|
|
|
|
2020-06-14 16:17:22 +00:00
|
|
|
CREATE TABLE data_null_error (
|
2020-05-25 18:58:30 +00:00
|
|
|
a Nullable(INT) NULL,
|
|
|
|
b INT NOT NULL,
|
|
|
|
c Nullable(INT)
|
2024-05-30 12:27:25 +00:00
|
|
|
) engine=Memory(); --{serverError ILLEGAL_SYNTAX_FOR_DATA_TYPE}
|
2020-05-25 18:58:30 +00:00
|
|
|
|
|
|
|
|
2020-06-14 16:17:22 +00:00
|
|
|
CREATE TABLE data_null_error (
|
2020-05-25 18:58:30 +00:00
|
|
|
a INT NULL,
|
|
|
|
b Nullable(INT) NOT NULL,
|
|
|
|
c Nullable(INT)
|
2024-05-30 12:27:25 +00:00
|
|
|
) engine=Memory(); --{serverError ILLEGAL_SYNTAX_FOR_DATA_TYPE}
|
2020-05-25 18:58:30 +00:00
|
|
|
|
|
|
|
SET data_type_default_nullable='true';
|
|
|
|
|
|
|
|
CREATE TABLE set_null (
|
|
|
|
a INT NULL,
|
|
|
|
b INT NOT NULL,
|
|
|
|
c Nullable(INT),
|
2022-05-16 22:09:23 +00:00
|
|
|
d INT,
|
|
|
|
f DEFAULT 1
|
2020-05-25 18:58:30 +00:00
|
|
|
) engine=Memory();
|
|
|
|
|
|
|
|
|
2022-05-16 22:09:23 +00:00
|
|
|
INSERT INTO set_null VALUES (NULL, 2, NULL, NULL, NULL);
|
2020-05-25 18:58:30 +00:00
|
|
|
|
2022-05-16 22:09:23 +00:00
|
|
|
SELECT toTypeName(a), toTypeName(b), toTypeName(c), toTypeName(d), toTypeName(f) FROM set_null;
|
2020-06-14 16:17:22 +00:00
|
|
|
|
|
|
|
SHOW CREATE TABLE set_null;
|
2021-04-16 10:15:35 +00:00
|
|
|
DETACH TABLE set_null;
|
|
|
|
ATTACH TABLE set_null;
|
|
|
|
SHOW CREATE TABLE set_null;
|
|
|
|
|
2024-05-30 12:27:25 +00:00
|
|
|
CREATE TABLE cannot_be_nullable (n Int8, a Array(UInt8)) ENGINE=Memory; -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
|
2021-04-16 10:15:35 +00:00
|
|
|
CREATE TABLE cannot_be_nullable (n Int8, a Array(UInt8) NOT NULL) ENGINE=Memory;
|
|
|
|
SHOW CREATE TABLE cannot_be_nullable;
|
|
|
|
DETACH TABLE cannot_be_nullable;
|
|
|
|
ATTACH TABLE cannot_be_nullable;
|
|
|
|
SHOW CREATE TABLE cannot_be_nullable;
|
2020-06-14 16:17:22 +00:00
|
|
|
|
|
|
|
DROP TABLE data_null;
|
|
|
|
DROP TABLE set_null;
|
2021-04-16 10:15:35 +00:00
|
|
|
DROP TABLE cannot_be_nullable;
|