Created
April 20, 2018 23:56
-
-
Save hatarist/5e7653808e59349c34d4589b2fc69b14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:) CREATE TABLE my_table (date Date DEFAULT today(), s String) ENGINE = MergeTree(date, (date), 8192); | |
:) INSERT INTO my_table (s) VALUES ('1. foo'); | |
:) ALTER TABLE my_table ADD COLUMN f Float64; | |
:) INSERT INTO my_table (s) VALUES ('2. bar'); | |
:) SELECT * FROM my_table; | |
┌───────date─┬─s──────┬─f─┐ | |
│ 2018-04-20 │ 1. foo │ 0 │ | |
│ 2018-04-20 │ 2. bar │ 0 │ | |
└────────────┴────────┴───┘ | |
:) ALTER TABLE my_table MODIFY COLUMN f Float64 DEFAULT -1; | |
:) SELECT * FROM my_table; | |
┌───────date─┬─s──────┬──f─┐ | |
│ 2018-04-20 │ 2. bar │ 0 │ | |
│ 2018-04-20 │ 1. foo │ -1 │ | |
└────────────┴────────┴────┘ | |
:) INSERT INTO my_table (s) VALUES ('3. baz'); | |
:) SELECT * FROM my_table; | |
┌───────date─┬─s──────┬──f─┐ | |
│ 2018-04-20 │ 2. bar │ 0 │ | |
│ 2018-04-20 │ 3. baz │ -1 │ | |
│ 2018-04-20 │ 1. foo │ -1 │ | |
└────────────┴────────┴────┘ | |
:) ALTER TABLE my_table MODIFY COLUMN f Float64 DEFAULT 123; | |
:) SELECT * FROM my_table; | |
┌───────date─┬─s──────┬───f─┐ | |
│ 2018-04-20 │ 3. baz │ -1 │ | |
│ 2018-04-20 │ 2. bar │ 0 │ | |
│ 2018-04-20 │ 1. foo │ 123 │ | |
└────────────┴────────┴─────┘ | |
:) ALTER TABLE my_table MODIFY COLUMN f Float64 DEFAULT 234; | |
:) SELECT * FROM my_table; | |
┌───────date─┬─s──────┬───f─┐ | |
│ 2018-04-20 │ 3. baz │ -1 │ | |
│ 2018-04-20 │ 2. bar │ 0 │ | |
│ 2018-04-20 │ 1. foo │ 234 │ | |
└────────────┴────────┴─────┘ | |
:) INSERT INTO my_table (s) VALUES ('4. wtf'); | |
:) ALTER TABLE my_table MODIFY COLUMN f Float64 DEFAULT 1337; | |
:) SELECT * FROM my_table; | |
┌───────date─┬─s──────┬────f─┐ | |
│ 2018-04-20 │ 2. bar │ 0 │ | |
│ 2018-04-20 │ 3. baz │ -1 │ | |
│ 2018-04-20 │ 4. wtf │ 234 │ | |
│ 2018-04-20 │ 1. foo │ 1337 │ | |
└────────────┴────────┴──────┘ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment