ClickHouse/tests/queries/0_stateless/00725_comment_columns_long.sql

93 lines
3.1 KiB
MySQL
Raw Normal View History

2021-09-12 12:35:27 +00:00
-- Tags: long
2019-06-07 16:02:24 +00:00
DROP TABLE IF EXISTS check_query_comment_column;
2018-11-15 13:12:27 +00:00
-- Check COMMENT COLUMN and MODIFY COLUMN statements with simple engine
2019-06-07 16:02:24 +00:00
CREATE TABLE check_query_comment_column
(
2018-11-15 13:12:27 +00:00
first_column UInt8 DEFAULT 1 COMMENT 'comment 1',
second_column UInt8 MATERIALIZED first_column COMMENT 'comment 2',
third_column UInt8 ALIAS second_column COMMENT 'comment 3',
fourth_column UInt8 COMMENT 'comment 4',
fifth_column UInt8
) ENGINE = TinyLog;
2019-06-07 16:02:24 +00:00
SHOW CREATE TABLE check_query_comment_column;
DESCRIBE TABLE check_query_comment_column;
SELECT table, name, comment
FROM system.columns
2019-06-07 16:02:24 +00:00
WHERE table = 'check_query_comment_column' AND database = currentDatabase()
FORMAT PrettyCompactNoEscapes;
2019-06-07 16:02:24 +00:00
ALTER TABLE check_query_comment_column
2018-11-15 13:12:27 +00:00
COMMENT COLUMN first_column 'comment 1_1',
COMMENT COLUMN second_column 'comment 2_1',
COMMENT COLUMN third_column 'comment 3_1',
COMMENT COLUMN fourth_column 'comment 4_1',
COMMENT COLUMN fifth_column 'comment 5_1';
2019-06-07 16:02:24 +00:00
SHOW CREATE TABLE check_query_comment_column;
2019-06-07 16:02:24 +00:00
ALTER TABLE check_query_comment_column
2018-11-15 13:12:27 +00:00
MODIFY COLUMN first_column COMMENT 'comment 1_2',
MODIFY COLUMN second_column COMMENT 'comment 2_2',
MODIFY COLUMN third_column COMMENT 'comment 3_2',
MODIFY COLUMN fourth_column COMMENT 'comment 4_2',
MODIFY COLUMN fifth_column COMMENT 'comment 5_2';
SELECT table, name, comment
FROM system.columns
2019-06-07 16:02:24 +00:00
WHERE table = 'check_query_comment_column' AND database = currentDatabase()
FORMAT PrettyCompactNoEscapes;
2019-06-07 16:02:24 +00:00
SHOW CREATE TABLE check_query_comment_column;
DROP TABLE IF EXISTS check_query_comment_column;
2018-11-15 13:12:27 +00:00
-- Check `ALTER TABLE table_name COMMENT COLUMN 'comment'` statement with MergeTree engine
2019-06-07 16:02:24 +00:00
CREATE TABLE check_query_comment_column
(
2018-11-15 13:12:27 +00:00
first_column UInt8 COMMENT 'comment 1',
second_column UInt8 COMMENT 'comment 2',
third_column UInt8 COMMENT 'comment 3'
) ENGINE = MergeTree()
ORDER BY first_column
PARTITION BY second_column
SAMPLE BY first_column;
2019-06-07 16:02:24 +00:00
SHOW CREATE TABLE check_query_comment_column;
DESCRIBE TABLE check_query_comment_column;
SELECT table, name, comment
FROM system.columns
2019-06-07 16:02:24 +00:00
WHERE table = 'check_query_comment_column' AND database = currentDatabase()
FORMAT PrettyCompactNoEscapes;
2019-06-07 16:02:24 +00:00
ALTER TABLE check_query_comment_column
2018-11-15 13:12:27 +00:00
COMMENT COLUMN first_column 'comment 1_2',
COMMENT COLUMN second_column 'comment 2_2',
COMMENT COLUMN third_column 'comment 3_2';
2019-06-07 16:02:24 +00:00
SHOW CREATE TABLE check_query_comment_column;
2019-06-07 16:02:24 +00:00
ALTER TABLE check_query_comment_column
2018-11-15 13:12:27 +00:00
MODIFY COLUMN first_column COMMENT 'comment 1_3',
MODIFY COLUMN second_column COMMENT 'comment 2_3',
MODIFY COLUMN third_column COMMENT 'comment 3_3';
2019-06-07 16:02:24 +00:00
SHOW CREATE TABLE check_query_comment_column;
2019-06-07 16:02:24 +00:00
ALTER TABLE check_query_comment_column
2018-11-15 13:12:27 +00:00
MODIFY COLUMN first_column DEFAULT 1 COMMENT 'comment 1_3',
MODIFY COLUMN second_column COMMENT 'comment 2_3', -- We can't change default value of partition key.
MODIFY COLUMN third_column DEFAULT 1 COMMENT 'comment 3_3';
SELECT table, name, comment
FROM system.columns
2019-06-07 16:02:24 +00:00
WHERE table = 'check_query_comment_column' and database = currentDatabase()
FORMAT PrettyCompactNoEscapes;
2019-06-07 16:02:24 +00:00
DROP TABLE IF EXISTS check_query_comment_column;
2018-11-15 13:12:27 +00:00
-- TODO: add here tests with ReplicatedMergeTree({database})