2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists defaulted;
|
2014-11-11 16:30:17 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
create table defaulted (col1 default 0) engine=Memory;
|
|
|
|
desc table defaulted;
|
|
|
|
drop table defaulted;
|
2014-11-11 16:30:17 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
create table defaulted (col1 UInt32, col2 default col1 + 1, col3 materialized col1 + 2, col4 alias col1 + 3) engine=Memory;
|
|
|
|
desc table defaulted;
|
|
|
|
insert into defaulted (col1) values (10);
|
|
|
|
select * from defaulted;
|
|
|
|
select col3, col4 from defaulted;
|
|
|
|
drop table defaulted;
|
2014-11-11 16:30:17 +00:00
|
|
|
|
2024-05-30 12:27:25 +00:00
|
|
|
create table defaulted (col1 Int8, col2 UInt64 default (SELECT dummy+99 from system.one)) engine=Memory; --{serverError THERE_IS_NO_DEFAULT_VALUE}
|
2017-06-06 14:18:23 +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 defaulted (payload String, date materialized today(), key materialized 0 * rand()) engine=MergeTree(date, key, 8192);
|
|
|
|
desc table defaulted;
|
|
|
|
insert into defaulted (payload) values ('hello clickhouse');
|
|
|
|
select * from defaulted;
|
2020-02-20 09:22:17 +00:00
|
|
|
alter table defaulted add column payload_length UInt64 materialized length(payload);
|
2019-04-16 14:13:13 +00:00
|
|
|
desc table defaulted;
|
|
|
|
select *, payload_length from defaulted;
|
|
|
|
insert into defaulted (payload) values ('some string');
|
|
|
|
select *, payload_length from defaulted order by payload;
|
|
|
|
select *, payload_length from defaulted order by payload;
|
|
|
|
alter table defaulted modify column payload_length default length(payload);
|
|
|
|
desc table defaulted;
|
|
|
|
select * from defaulted order by payload;
|
|
|
|
alter table defaulted modify column payload_length default length(payload) % 65535;
|
|
|
|
desc table defaulted;
|
|
|
|
select * from defaulted order by payload;
|
|
|
|
alter table defaulted modify column payload_length UInt16 default length(payload);
|
|
|
|
desc table defaulted;
|
|
|
|
alter table defaulted drop column payload_length;
|
|
|
|
desc table defaulted;
|
|
|
|
select * from defaulted order by payload;
|
|
|
|
drop table defaulted;
|