ClickHouse/dbms/tests/queries/0_stateless/00061_merge_tree_alter.sql

85 lines
2.4 KiB
MySQL
Raw Normal View History

2014-07-14 12:09:15 +00:00
DROP TABLE IF EXISTS test.alter;
CREATE TABLE test.alter (d Date, k UInt64, i32 Int32) ENGINE=MergeTree(d, k, 8192);
INSERT INTO test.alter VALUES ('2015-01-01', 10, 42);
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
ALTER TABLE test.alter ADD COLUMN dt DateTime;
INSERT INTO test.alter VALUES ('2015-01-01', 9, 41, '1992-01-01 08:00:00');
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
ALTER TABLE test.alter ADD COLUMN n Nested(ui8 UInt8, s String);
INSERT INTO test.alter VALUES ('2015-01-01', 8, 40, '2012-12-12 12:12:12', [1,2,3], ['12','13','14']);
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
ALTER TABLE test.alter ADD COLUMN `n.d` Array(Date);
INSERT INTO test.alter VALUES ('2015-01-01', 7, 39, '2014-07-14 13:26:50', [10,20,30], ['120','130','140'],['2000-01-01','2000-01-01','2000-01-03']);
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
2016-08-02 19:22:46 +00:00
ALTER TABLE test.alter ADD COLUMN s String DEFAULT '0';
2014-07-14 12:09:15 +00:00
INSERT INTO test.alter VALUES ('2015-01-01', 6,38,'2014-07-15 13:26:50',[10,20,30],['asd','qwe','qwe'],['2000-01-01','2000-01-01','2000-01-03'],'100500');
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
ALTER TABLE test.alter DROP COLUMN `n.d`, MODIFY COLUMN s Int64;
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
ALTER TABLE test.alter ADD COLUMN `n.d` Array(Date), MODIFY COLUMN s UInt32;
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
OPTIMIZE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
ALTER TABLE test.alter DROP COLUMN n.ui8, DROP COLUMN n.d;
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
ALTER TABLE test.alter DROP COLUMN n.s;
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
ALTER TABLE test.alter ADD COLUMN n.s Array(String), ADD COLUMN n.d Array(Date);
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
ALTER TABLE test.alter DROP COLUMN n;
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
2014-07-17 14:41:43 +00:00
ALTER TABLE test.alter MODIFY COLUMN dt Date, MODIFY COLUMN s DateTime;
2014-07-14 12:09:15 +00:00
DESC TABLE test.alter;
SHOW CREATE TABLE test.alter;
2014-07-14 16:00:57 +00:00
SELECT * FROM test.alter ORDER BY k;
2014-07-14 12:09:15 +00:00
DROP TABLE test.alter;