| 1 |
SET @@session.default_storage_engine = 'ndbcluster'; |
| 2 |
create table stored_basic |
| 3 |
(i int not null primary key, |
| 4 |
gcol_int int GENERATED ALWAYS AS (100 + i) STORED, |
| 5 |
misc int, |
| 6 |
gcol_str varchar(20) GENERATED ALWAYS AS (concat("User ", i)) STORED |
| 7 |
); |
| 8 |
insert into stored_basic(i) values(1), (2), (3), (4), (5); |
| 9 |
select * from stored_basic order by i; |
| 10 |
i gcol_int misc gcol_str |
| 11 |
1 101 NULL User 1 |
| 12 |
2 102 NULL User 2 |
| 13 |
3 103 NULL User 3 |
| 14 |
4 104 NULL User 4 |
| 15 |
5 105 NULL User 5 |
| 16 |
delete from stored_basic where i = 1; |
| 17 |
affected rows: 1 |
| 18 |
delete from stored_basic where gcol_int = 102; |
| 19 |
affected rows: 1 |
| 20 |
delete from stored_basic where misc is null; |
| 21 |
affected rows: 3 |
| 22 |
insert into stored_basic(i) values(1), (2), (3), (4), (5); |
| 23 |
select gcol_str from stored_basic; |
| 24 |
gcol_str |
| 25 |
User 1 |
| 26 |
User 2 |
| 27 |
User 3 |
| 28 |
User 4 |
| 29 |
User 5 |
| 30 |
update stored_basic set gcol_int = 44 where i = 4; |
| 31 |
ERROR HY000: The value specified for generated column 'gcol_int' in table 'stored_basic' is not allowed. |
| 32 |
update stored_basic set misc = 44 where gcol_int = 104; |
| 33 |
create table stored_basic_2 like stored_basic; |
| 34 |
insert into stored_basic_2 (i,misc) select i,misc from stored_basic; |
| 35 |
select * from stored_basic_2 order by i; |
| 36 |
i gcol_int misc gcol_str |
| 37 |
1 101 NULL User 1 |
| 38 |
2 102 NULL User 2 |
| 39 |
3 103 NULL User 3 |
| 40 |
4 104 44 User 4 |
| 41 |
5 105 NULL User 5 |
| 42 |
drop table stored_basic_2; |
| 43 |
drop table stored_basic; |