2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE IF EXISTS alter_test;
|
2014-04-03 15:57:36 +00:00
|
|
|
|
2022-06-23 08:37:52 +00:00
|
|
|
set allow_deprecated_syntax_for_merge_tree=1;
|
2019-04-16 14:13:13 +00:00
|
|
|
CREATE TABLE alter_test (CounterID UInt32, StartDate Date, UserID UInt32, VisitID UInt32, NestedColumn Nested(A UInt8, S String), ToDrop UInt32) ENGINE = MergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192);
|
2014-04-03 15:57:36 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
INSERT INTO alter_test VALUES (1, '2014-01-01', 2, 3, [1,2,3], ['a','b','c'], 4);
|
2014-04-03 15:57:36 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
ALTER TABLE alter_test ADD COLUMN Added0 UInt32;
|
|
|
|
ALTER TABLE alter_test ADD COLUMN Added2 UInt32;
|
|
|
|
ALTER TABLE alter_test ADD COLUMN Added1 UInt32 AFTER Added0;
|
2014-04-03 15:57:36 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
ALTER TABLE alter_test ADD COLUMN AddedNested1 Nested(A UInt32, B UInt64) AFTER Added2;
|
|
|
|
ALTER TABLE alter_test ADD COLUMN AddedNested1.C Array(String) AFTER AddedNested1.B;
|
|
|
|
ALTER TABLE alter_test ADD COLUMN AddedNested2 Nested(A UInt32, B UInt64) AFTER AddedNested1;
|
2014-05-20 15:42:59 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
DESC TABLE alter_test;
|
2017-08-18 20:11:09 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
ALTER TABLE alter_test DROP COLUMN ToDrop;
|
2017-08-18 20:11:09 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
ALTER TABLE alter_test MODIFY COLUMN Added0 String;
|
2017-08-18 20:11:09 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
ALTER TABLE alter_test DROP COLUMN NestedColumn.A;
|
|
|
|
ALTER TABLE alter_test DROP COLUMN NestedColumn.S;
|
2017-08-18 20:11:09 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
ALTER TABLE alter_test DROP COLUMN AddedNested1.B;
|
2017-08-18 20:11:09 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
ALTER TABLE alter_test ADD COLUMN IF NOT EXISTS Added0 UInt32;
|
|
|
|
ALTER TABLE alter_test ADD COLUMN IF NOT EXISTS AddedNested1 Nested(A UInt32, B UInt64);
|
|
|
|
ALTER TABLE alter_test ADD COLUMN IF NOT EXISTS AddedNested1.C Array(String);
|
|
|
|
ALTER TABLE alter_test MODIFY COLUMN IF EXISTS ToDrop UInt64;
|
|
|
|
ALTER TABLE alter_test DROP COLUMN IF EXISTS ToDrop;
|
|
|
|
ALTER TABLE alter_test COMMENT COLUMN IF EXISTS ToDrop 'new comment';
|
2018-12-21 14:53:00 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
DESC TABLE alter_test;
|
2017-08-18 20:11:09 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT * FROM alter_test;
|
2017-08-18 20:11:09 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE alter_test;
|