mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 21:24:28 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
31 lines
1.1 KiB
SQL
31 lines
1.1 KiB
SQL
DROP TABLE IF EXISTS table_with_defaults_on_aliases;
|
|
|
|
CREATE TABLE table_with_defaults_on_aliases (col1 UInt32, col2 ALIAS col1, col3 DEFAULT col2) Engine = MergeTree() ORDER BY tuple();
|
|
|
|
INSERT INTO table_with_defaults_on_aliases (col1) VALUES (1);
|
|
|
|
SELECT * FROM table_with_defaults_on_aliases WHERE col1 = 1;
|
|
|
|
SELECT col1, col2, col3 FROM table_with_defaults_on_aliases WHERE col1 = 1;
|
|
|
|
ALTER TABLE table_with_defaults_on_aliases ADD COLUMN col4 UInt64 DEFAULT col2 * col3;
|
|
|
|
INSERT INTO table_with_defaults_on_aliases (col1) VALUES (2);
|
|
|
|
SELECT * FROM table_with_defaults_on_aliases WHERE col1 = 2;
|
|
|
|
SELECT col1, col2, col3, col4 FROM table_with_defaults_on_aliases WHERE col1 = 2;
|
|
|
|
ALTER TABLE table_with_defaults_on_aliases ADD COLUMN col5 UInt64 ALIAS col2 * col4;
|
|
|
|
INSERT INTO table_with_defaults_on_aliases (col1) VALUES (3);
|
|
|
|
SELECT * FROM table_with_defaults_on_aliases WHERE col1 = 3;
|
|
|
|
SELECT col1, col2, col3, col4, col5 FROM table_with_defaults_on_aliases WHERE col1 = 3;
|
|
|
|
|
|
ALTER TABLE table_with_defaults_on_aliases ADD COLUMN col6 UInt64 MATERIALIZED col2 * col4;
|
|
|
|
DROP TABLE IF EXISTS table_with_defaults_on_aliases;
|