github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/snapshot/snapshotRead.sql (about) 1 -- create/drop 2 -- A tenant creates snapshot backup, view creation information through show snapshots 3 drop database if exists test; 4 create database test; 5 use test; 6 drop table if exists snapshot01; 7 create table snapshot01 (col1 int primary key , col2 decimal, col3 bigint, col4 double, col5 float); 8 insert into snapshot01 values (1, 10.50, 1234567890, 123.45, 678.90), 9 (2, 20.75, 9876543210, 234.56, 789.01), 10 (3, 30.10, 1122334455, 345.67, 890.12), 11 (4, 40.25, 2233445566, 456.78, 901.23), 12 (5, 50.40, -3344556677, 567.89, 101.24), 13 (6, 60.55, -4455667788, 678.90, 112.35), 14 (7, 70.70, 5566778899, 789.01, 123.46), 15 (8, 80.85, -6677889900, 890.12, 134.57), 16 (9, 90.00, 7788990011, 901.23, 145.68), 17 (10, 100.00, 8899001122, 101.24, 156.79); 18 select count(*) from snapshot01; 19 select * from snapshot01; 20 show create table snapshot01; 21 drop snapshot if exists sp01; 22 create snapshot sp01 for account sys; 23 select * from snapshot01 {snapshot = 'sp01'}; 24 select count(*) from snapshot01 {snapshot = 'sp01'}; 25 26 -- @ignore:1 27 show snapshots where SNAPSHOT_NAME = 'sp01'; 28 insert into snapshot01 values(11, 100.00, 8899001122, 101.24, 156.79); 29 select count(*) from snapshot01; 30 select count(*) from snapshot01 {snapshot = 'sp01'}; 31 select * from snapshot01 {snapshot = 'sp01'}; 32 33 update snapshot01 set col1 = 100 where col1 = 243214312; 34 select count(*) from snapshot01; 35 select count(*) from snapshot01 {snapshot = 'sp01'}; 36 select * from snapshot01 {snapshot = 'sp01'}; 37 38 delete from snapshot01 where col1 < 10; 39 select count(*) from snapshot01; 40 select count(*) from snapshot01 {snapshot = 'sp01'}; 41 select * from snapshot01 {snapshot = 'sp01'}; 42 43 alter table snapshot01 add column column1 bigint first; 44 show create table snapshot01; 45 select count(*) from snapshot01; 46 select * from snapshot01; 47 select count(*) from snapshot01 {snapshot = 'sp01'}; 48 select * from snapshot01 {snapshot = 'sp01'}; 49 50 truncate table snapshot01; 51 show create table snapshot01; 52 select count(*) from snapshot01; 53 select * from snapshot01; 54 select count(*) from snapshot01 {snapshot = 'sp01'}; 55 select * from snapshot01 {snapshot = 'sp01'}; 56 57 drop table snapshot01; 58 select count(*) from snapshot01; 59 select count(*) from snapshot01 {snapshot = 'sp01'}; 60 select * from snapshot01 {snapshot = 'sp01'}; 61 select count(*) from mo_catalog.mo_tables{snapshot = 'sp01'} where reldatabase = 'test'; 62 -- @ignore:0,6,7 63 select * from mo_catalog.mo_database{snapshot = 'sp01'} where datname = 'test'; 64 select attname from mo_catalog.mo_columns{snapshot = 'sp01'} where att_database = 'test'; 65 drop snapshot sp01; 66 show snapshots; 67 select count(*) from mo_catalog.mo_tables{snapshot = 'sp01'} where reldatabase = 'test'; 68 -- @ignore:0,6,7 69 select * from mo_catalog.mo_database{snapshot = 'sp01'} where datname = 'test'; 70 select attname from mo_catalog.mo_columns{snapshot = 'sp01'} where att_database = 'test'; 71 72 -- create snapshot while snapshot exists 73 drop table if exists snapshot02; 74 create table test_snapshot_read (a int); 75 insert into test_snapshot_read (a) VALUES(1), (2), (3), (4), (5),(6), (7), (8), (9), (10), (11), (12),(13), (14), (15), (16), (17), (18), (19), (20),(21), (22), (23), (24), (25), (26), (27), (28), (29), (30),(31), (32), (33), (34), (35), (36), (37), (38), (39), (40),(41), (42), (43), (44), (45), (46), (47), (48), (49), (50),(51), (52), (53), (54), (55), (56), (57), (58), (59), (60),(61), (62), (63), (64), (65), (66), (67), (68), (69), (70),(71), (72), (73), (74), (75), (76), (77), (78), (79), (80), (81), (82), (83), (84), (85), (86), (87), (88), (89), (90),(91), (92), (93), (94), (95), (96), (97), (98), (99), (100); 76 select count(*) from test_snapshot_read; 77 create snapshot snapshot_01 for account sys; 78 create snapshot snapshot_01 for account sys; 79 drop snapshot snapshot_01; 80 drop table test_snapshot_read; 81 82 -- create more snapshot 83 drop table if exists snapshot03; 84 drop table if exists snapshot04; 85 create table snapshot03(col1 int unique key, 86 col2 varchar(20), 87 col3 int, 88 col4 bigint); 89 create table snapshot04(col1 int, 90 col2 int, 91 col3 int primary key, 92 constraint `c1` foreign key(col1) references snapshot03(col1)); 93 show create table snapshot03; 94 show create table snapshot04; 95 insert into snapshot03 values(1,'sfhuwe',1,1); 96 insert into snapshot03 values(2,'37829901k3d',2,2); 97 insert into snapshot04 values(1,1,1); 98 insert into snapshot04 values(2,2,2); 99 select * from snapshot03; 100 select * from snapshot04; 101 102 drop snapshot if exists sp03; 103 create snapshot sp03 for account sys; 104 -- @ignore:1 105 show snapshots where account_name = 'sys'; 106 insert into snapshot03 values(3,'sfhuwe',1,1); 107 insert into snapshot03 values(4,'37829901k3d',2,2); 108 drop snapshot if exists sp04; 109 create snapshot sp04 for account sys; 110 -- @ignore:1 111 show snapshots; 112 select * from snapshot03; 113 select count(*) from snapshot03 {snapshot = 'sp03'}; 114 select * from snapshot03{snapshot = 'sp03'}; 115 select count(*) from snapshot04 {snapshot = 'sp03'}; 116 select * from snapshot04{snapshot = 'sp03'}; 117 select count(*) from snapshot03 {snapshot = 'sp04'}; 118 select * from snapshot03{snapshot = 'sp04'}; 119 120 alter table snapshot03 drop column col4; 121 insert into snapshot03 values(5,'sfhuwe',1); 122 select * from snapshot03; 123 select count(*) from snapshot03 {snapshot = 'sp03'}; 124 drop snapshot if exists sp05; 125 create snapshot sp05 for account sys; 126 -- @ignore:1 127 show snapshots; 128 select count(*) from snapshot03 {snapshot = 'sp05'}; 129 select * from snapshot03{snapshot = 'sp05'}; 130 select count(*) from mo_catalog.mo_tables{snapshot = 'sp03'} where reldatabase = 'test'; 131 -- @ignore:0,6,7 132 select * from mo_catalog.mo_database{snapshot = 'sp04'} where datname = 'test'; 133 select attname from mo_catalog.mo_columns{snapshot = 'sp05'} where att_database = 'test'; 134 135 drop snapshot sp05; 136 drop snapshot sp04; 137 drop snapshot sp03; 138 drop table snapshot04; 139 drop table snapshot03; 140 drop database test; 141 142 -- sys account creates snapshot for non-sys tenant 143 drop account if exists acc01; 144 create account acc01 admin_name = 'test_account' identified by '111'; 145 -- @session:id=3&user=acc01:test_account&password=111 146 drop database if exists test01; 147 create database test01; 148 use test01; 149 drop table if exists acc01_snap; 150 create table acc01_snap(col1 int, col2 char, col3 binary, primary key(col1, col2)); 151 insert into acc01_snap values (1, 'a', '1'); 152 insert into acc01_snap values (2, 'a', '1'); 153 insert into acc01_snap values (10, 'm', null); 154 select * from acc01_snap; 155 -- @session 156 drop snapshot if exists snap01; 157 create snapshot snap01 for account acc01; 158 -- @ignore:1 159 show snapshots; 160 -- @session:id=4&user=acc01:test_account&password=111 161 use test01; 162 show snapshots; 163 -- @session 164 select count(*) from acc01_snap{snapshot = 'snap01'}; 165 select count(*) from mo_catalog.mo_tables{snapshot = 'snap01'} where reldatabase = 'test01'; 166 -- @ignore:0,6,7 167 select * from mo_catalog.mo_database{snapshot = 'snap01'} where datname = 'test01'; 168 select attname from mo_catalog.mo_columns{snapshot = 'snap01'} where att_database = 'test01'; 169 -- @session:id=5&user=acc01:test_account&password=111 170 drop database test01; 171 -- @session 172 select count(*) from mo_catalog.mo_tables{snapshot = 'snap01'} where reldatabase = 'test01'; 173 -- @ignore:0,6,7 174 select * from mo_catalog.mo_database{snapshot = 'snap01'} where datname = 'test01'; 175 select attname from mo_catalog.mo_columns{snapshot = 'snap01'} where att_database = 'test01'; 176 drop snapshot snap01; 177 drop account acc01; 178 179 -- non-sys account create snapshot for non-sys account 180 drop account if exists acc02; 181 create account acc02 admin_name = 'test_account' identified by '111'; 182 -- @session:id=6&user=acc02:test_account&password=111 183 drop database if exists test02; 184 create database test02; 185 use test02; 186 drop table if exists acc02_test01; 187 create table acc02_test01 (col1 decimal, col2 char, col3 varchar(30), col4 float); 188 insert into acc02_test01 values (3242.234234, '1', 'weawf3redwe', 38293.3232); 189 insert into acc02_test01 values (323.32411, 'a', '3233234213', 323231221); 190 insert into acc02_test01 values (-32323, 'v', 'wqd3wq', -323232); 191 select count(*) from acc02_test01; 192 drop snapshot if exists snap02; 193 create snapshot snap02 for account acc02; 194 -- @ignore:1 195 show snapshots; 196 -- @ignore:1 197 show snapshots where account_name = 'acc02'; 198 select count(*) from acc02_test01 {snapshot = 'snap02'}; 199 select * from acc02_test01 {snapshot = 'snap02'}; 200 alter table acc02_test01 add column new int first; 201 show create table acc02_test01; 202 select count(*) from acc02_test01 {snapshot = 'snap02'}; 203 select * from acc02_test01 {snapshot = 'snap02'}; 204 truncate acc02_test01; 205 select count(*) from acc02_test01 {snapshot = 'snap02'}; 206 select * from acc02_test01 {snapshot = 'snap02'}; 207 insert into acc02_test01 values(1,1,2,3,4); 208 select count(*) from acc02_test01 {snapshot = 'snap02'}; 209 select * from acc02_test01 {snapshot = 'snap02'}; 210 select count(*) from mo_catalog.mo_tables{snapshot = 'snap02'} where reldatabase = 'test02'; 211 -- @ignore:0,6,7 212 select * from mo_catalog.mo_database{snapshot = 'snap02'} where datname = 'test02'; 213 select attname from mo_catalog.mo_columns{snapshot = 'snap02'} where att_database = 'test02'; 214 drop snapshot snap02; 215 drop table acc02_test01; 216 drop database test02; 217 -- @session 218 drop account acc02; 219 220 -- select where 221 drop database if exists test03; 222 create database test03; 223 use test03; 224 drop table if exists testsnap_03; 225 create table testsnap_03 ( 226 employeeNumber int(11) not null , 227 lastName char(50) not null , 228 firstName char(50) not null , 229 extension char(10) not null , 230 email char(100) not null , 231 officeCode char(10) not null , 232 reportsTo int(11) DEFAULT NULL, 233 jobTitle char(50) not null , 234 key (employeeNumber) 235 ); 236 insert into testsnap_03(employeeNumber,lastName,firstName,extension,email,officeCode,reportsTo,jobTitle) values 237 (1002,'Murphy','Diane','x5800','dmurphy@classicmodelcars.com','1',NULL,'President'), 238 (1056,'Patterson','Mary','x4611','mpatterso@classicmodelcars.com','1',1002,'VP Sales'), 239 (1076,'Firrelli','Jeff','x9273','jfirrelli@classicmodelcars.com','1',1002,'VP Marketing'), 240 (1088,'Patterson','William','x4871','wpatterson@classicmodelcars.com','6',1056,'Sales Manager (APAC)'), 241 (1102,'Bondur','Gerard','x5408','gbondur@classicmodelcars.com','4',1056,'Sale Manager (EMEA)'), 242 (1143,'Bow','Anthony','x5428','abow@classicmodelcars.com','1',1056,'Sales Manager (NA)'), 243 (1165,'Jennings','Leslie','x3291','ljennings@classicmodelcars.com','1',1143,'Sales Rep'), 244 (1166,'Thompson','Leslie','x4065','lthompson@classicmodelcars.com','1',1143,'Sales Rep'), 245 (1188,'Firrelli','Julie','x2173','jfirrelli@classicmodelcars.com','2',1143,'Sales Rep'), 246 (1216,'Patterson','Steve','x4334','spatterson@classicmodelcars.com','2',1143,'Sales Rep'); 247 248 drop snapshot if exists testsnap_03; 249 select count(*) from testsnap_03; 250 create snapshot sp04 for account sys; 251 select count(*) from testsnap_03 {snapshot = 'sp04'}; 252 insert into testsnap_03 values (1286,'Tseng','Foon Yue','x2248','ftseng@classicmodelcars.com','3',1143,'Sales Rep'), 253 (1323,'Vanauf','George','x4102','gvanauf@classicmodelcars.com','3',1143,'Sales Rep'), 254 (1337,'Bondur','Loui','x6493','lbondur@classicmodelcars.com','4',1102,'Sales Rep'), 255 (1370,'Hernandez','Gerard','x2028','ghernande@classicmodelcars.com','4',1102,'Sales Rep'), 256 (1401,'Castillo','Pamela','x2759','pcastillo@classicmodelcars.com','4',1102,'Sales Rep'); 257 select count(*) from testsnap_03 {snapshot = 'sp04'}; 258 drop snapshot if exists sp05; 259 create snapshot sp05 for account sys; 260 select * from testsnap_03; 261 select * from testsnap_03 {snapshot = 'sp04'} where jobTitle = 'President'; 262 select employeeNumber,lastName,firstName,extension from testsnap_03 {snapshot = 'sp04'} where extension = 'x4611'; 263 select count(*) from testsnap_03 {snapshot = 'sp04'} where employeeNumber > 1000; 264 drop table if exists testsnap_04; 265 create table testsnap_04 ( 266 employeeNumber int(11) not null , 267 lastName char(50) not null , 268 firstName char(50) not null , 269 extension char(10) not null 270 ); 271 insert into testsnap_04 select employeeNumber,lastName,firstName,extension from testsnap_03{snapshot = 'sp04'}; 272 select * from testsnap_04; 273 select * from testsnap_03 {snapshot = 'sp04'}; 274 select count(*) from mo_catalog.mo_tables{snapshot = 'sp04'} where reldatabase = 'test03'; 275 -- @ignore:0,6,7 276 select * from mo_catalog.mo_database{snapshot = 'sp04'} where datname = 'test03'; 277 select attname from mo_catalog.mo_columns{snapshot = 'sp04'} where att_database = 'test03'; 278 drop table testsnap_03; 279 drop table testsnap_04; 280 drop snapshot sp04; 281 drop snapshot sp05; 282 drop database test03; 283 284 -- create snapshot for cluster table 285 use mo_catalog; 286 drop table if exists cluster01; 287 create cluster table cluster01(col1 int,col2 bigint); 288 insert into cluster01 values(1,2,0); 289 insert into cluster01 values(2,3,0); 290 select * from cluster01; 291 drop snapshot if exists sp06; 292 create snapshot sp06 for account sys; 293 -- @bvt:issue#15901 294 select count(*) from mo_catalog.mo_tables{snapshot = sp06} where reldatabase = 'mo_catalog'; 295 -- @ignore:0,6,7 296 select * from mo_catalog.mo_database{snapshot = sp06} where datname = 'mo_catalog'; 297 select attname from mo_catalog.mo_columns{snapshot = sp06} where att_database = 'mo_catalog'; 298 -- @bvt:issue 299 drop table cluster01; 300 drop snapshot sp06; 301 302 -- pub table 303 drop database if exists test03; 304 create database test03; 305 use test03; 306 create table pub01 (col1 int primary key , col2 decimal, col3 bigint, col4 double, col5 float); 307 insert into pub01 values (1, 10.50, 1234567890, 123.45, 678.90), 308 (2, 20.75, 9876543210, 234.56, 789.01), 309 (3, 30.10, 1122334455, 345.67, 890.12), 310 (4, 40.25, 2233445566, 456.78, 901.23); 311 drop account if exists test_tenant_1; 312 create account test_tenant_1 admin_name 'test_account' identified by '111'; 313 create publication publication01 database test03 account test_tenant_1 comment 'publish database to account01'; 314 -- @session:id=7&user=test_tenant_1:test_account&password=111 315 create database sub_database01 from sys publication publication01; 316 show databases; 317 use sub_database01; 318 show tables; 319 -- @session 320 drop snapshot if exists sp06; 321 create snapshot sp06 for account sys; 322 select * from pub01 {snapshot = 'sp06'}; 323 select count(*) from pub01 {snapshot = 'sp06'}; 324 select count(*) from mo_catalog.mo_tables{snapshot = 'sp06'} where reldatabase = 'test03'; 325 -- @ignore:0,6,7 326 select * from mo_catalog.mo_database{snapshot = 'sp06'} where datname = 'test03'; 327 select attname from mo_catalog.mo_columns{snapshot = 'sp06'} where att_database = 'test03'; 328 -- @session:id=2&user=test_tenant_1:test_account&password=111 329 use sub_database01; 330 select count(*) from mo_catalog.mo_tables{snapshot = 'sp06'} where reldatabase = 'sub_database01'; 331 -- @ignore:0,6,7 332 select * from mo_catalog.mo_database{snapshot = 'sp06'} where datname = 'sub_database01'; 333 select attname from mo_catalog.mo_columns{snapshot = 'sp06'} where att_database = 'sub_database01'; 334 -- @session 335 drop account test_tenant_1; 336 drop publication publication01; 337 drop snapshot sp06; 338 drop table pub01; 339 340 -- table with partition by 341 drop table if exists pt_table; 342 create table pt_table(col1 tinyint,col2 smallint,col3 int,clo4 bigint,col5 tinyint unsigned,col6 smallint unsigned,col7 int unsigned,col8 bigint unsigned,col9 float,col10 double,col11 varchar(255),col12 Date,col13 DateTime,col14 timestamp,col15 bool,col16 decimal(5,2),col17 text,col18 varchar(255),col19 varchar(255),col20 text)partition by key(col13)partitions 10; 343 load data infile '$resources/external_table_file/pt_table_data.csv' into table pt_table fields terminated by ','; 344 select count(*) from pt_table; 345 drop snapshot if exists sp07; 346 create snapshot sp07 for account sys; 347 -- @ignore:1 348 show snapshots; 349 select count(*) from pt_table{snapshot = 'sp07'}; 350 show create table pt_table{snapshot = 'sp07'}; 351 select count(*) from mo_catalog.mo_tables{snapshot = 'sp07'} where reldatabase = 'test03'; 352 -- @ignore:0,6,7 353 select * from mo_catalog.mo_database{snapshot = 'sp07'} where datname = 'test03'; 354 select attname from mo_catalog.mo_columns{snapshot = 'sp07'} where att_database = 'test03'; 355 drop snapshot sp07; 356 drop table pt_table; 357 drop database test03; 358 359 -- A database contains multiple tables at the same time, including tables of any type 360 drop database if exists test04; 361 create database test04; 362 use test04; 363 drop table if exists normal_table01; 364 create table normal_table01 (col1 enum('a','b','c'), col2 date, col3 binary); 365 insert into normal_table01 values ('a', '2000-10-01', 'a'); 366 insert into normal_table01 values ('b', '2023-12-12', '1'); 367 insert into normal_table01 values ('c', '1999-11-11', 'c'); 368 select * from normal_table01; 369 use mo_catalog; 370 drop table if exists cluster02; 371 create cluster table cluster02(col1 timestamp, col2 varchar(20)); 372 insert into cluster02 values ('2000-12-12 12:12:12.000', 'database', 0); 373 insert into cluster02 values ('2024-01-12 11:11:29.000', 'cluster table', 0); 374 select * from cluster02; 375 use test04; 376 drop table if exists test04; 377 create table test04 (`maxvalue` int); 378 create table t3 (`maxvalue` int); 379 insert into t3 values(1); 380 insert into t3 values(2); 381 insert into t3 values(100); 382 insert into t3 values(-1000); 383 drop account if exists test_tenant_1; 384 create account test_tenant_1 admin_name 'test_account' identified by '111'; 385 create publication publication01 database test04 account test_tenant_1 comment 'publish database'; 386 -- @session:id=12&user=test_tenant_1:test_account&password=111 387 create database sub_database02 from sys publication publication01; 388 use sub_database02; 389 -- @session 390 drop snapshot if exists sp08; 391 create snapshot sp08 for account sys; 392 use test04; 393 select count(*) from normal_table01 {snapshot = 'sp08'}; 394 select count(*) from t3 {snapshot = 'sp08'}; 395 use mo_catalog; 396 select count(*) from cluster02 {snapshot = 'sp08'}; 397 use test04; 398 delete from normal_table01 where col1 = 'a'; 399 use mo_catalog; 400 update cluster02 set col2 = 'table'; 401 use test04; 402 insert into t3 values(218231); 403 select count(*) from normal_table01 {snapshot = 'sp08'}; 404 use mo_catalog; 405 select count(*) from cluster02 {snapshot = 'sp08'}; 406 use test04; 407 select count(*) from t3 {snapshot = 'sp08'}; 408 select count(*) from mo_catalog.mo_tables{snapshot = 'sp08'} where reldatabase = 'test04'; 409 drop account test_tenant_1; 410 -- @ignore:0,6,7 411 select * from mo_catalog.mo_database{snapshot = 'sp08'} where datname = 'test04'; 412 select attname from mo_catalog.mo_columns{snapshot = 'sp08'} where att_database = 'test04'; 413 select count(*) from mo_catalog.mo_tables{snapshot = 'sp08'} where reldatabase = 'test04'; 414 -- @ignore:0,6,7 415 select * from mo_catalog.mo_database{snapshot = 'sp08'} where datname = 'test04'; 416 select attname from mo_catalog.mo_columns{snapshot = 'sp08'} where att_database = 'test04'; 417 drop publication publication01; 418 drop table normal_table01; 419 use mo_catalog; 420 drop table cluster02; 421 use test04; 422 drop table t3; 423 drop database test04; 424 425 -- reserved keywords and non-reserved keywords as snapshot name 426 drop database if exists test05; 427 create database test05; 428 use test05; 429 drop table if exists t1; 430 create table t1 (a blob); 431 insert into t1 values('abcdef'); 432 insert into t1 values('_bcdef'); 433 insert into t1 values('a_cdef'); 434 insert into t1 values('ab_def'); 435 insert into t1 values('abc_ef'); 436 insert into t1 values('abcd_f'); 437 insert into t1 values('abcde_'); 438 select count(*) from t1; 439 drop snapshot if exists `binary`; 440 create snapshot `binary` for account sys; 441 -- @bvt:issue#15901 442 select count(*) from mo_catalog.mo_tables{snapshot = `binary`} where reldatabase = 'test05'; 443 -- @ignore:0,6,7 444 select * from mo_catalog.mo_database{snapshot = `binary`} where datname = 'test05'; 445 select attname from mo_catalog.mo_columns{snapshot = `binary`} where att_database = 'test05'; 446 -- @bvt:issue 447 drop snapshot `binary`; 448 drop table t1; 449 450 drop table if exists t1; 451 create table t1 ( 452 dvalue date not null, 453 value32 integer not null, 454 primary key(dvalue) 455 ); 456 insert into t1 values('2022-01-01', 1); 457 insert into t1 values('2022-01-02', 2); 458 drop snapshot if exists consistent; 459 create snapshot consistent for account sys; 460 -- @bvt:issue#15901 461 select count(*) from mo_catalog.mo_tables{snapshot = consistent} where reldatabase = 'test05'; 462 -- @ignore:0,6,7 463 select * from mo_catalog.mo_database{snapshot = consistent} where datname = 'test05'; 464 select attname from mo_catalog.mo_columns{snapshot = consistent} where att_database = 'test05'; 465 -- @bvt:issue 466 drop snapshot consistent; 467 drop table t1; 468 drop database if exists test05; 469 470 -- create snapshot in explicit transaction 471 drop database if exists test06; 472 create database test06; 473 use test06; 474 drop table if exists tran01; 475 start transaction; 476 create table tran01(col1 enum('red','blue','green')); 477 insert into tran01 values('red'),('blue'),('green'); 478 create snapshot sp09 for account sys; 479 -- @ignore:1 480 show snapshots; 481 commit; 482 drop snapshot if exists sp09; 483 create snapshot sp09 for account sys; 484 -- @ignore:1 485 show snapshots; 486 select count(*) from tran01{snapshot = 'sp09'}; 487 select count(*) from mo_catalog.mo_tables{snapshot = 'sp09'} where reldatabase = 'test06'; 488 -- @ignore:0,6,7 489 select * from mo_catalog.mo_database{snapshot = 'sp09'} where datname = 'test06'; 490 select attname from mo_catalog.mo_columns{snapshot = 'sp09'} where att_database = 'test06'; 491 drop table tran01; 492 drop snapshot sp09; 493 drop database test06; 494 495 -- verify that data outside the snapshot is deleted by gc 496 drop database if exists test07; 497 create database test07; 498 use test07; 499 drop table if exists t1; 500 create table t1(a int, b char(10), c date, d decimal(7,2), UNIQUE KEY(a, b)); 501 desc t1; 502 insert into t1 values(1, 'ab', '1980-12-17', 800); 503 insert into t1 values(2, 'ac', '1981-02-20', 1600); 504 insert into t1 values(3, 'ad', '1981-02-22', 500); 505 select * from t1; 506 507 drop table if exists t2; 508 create table t2 (a json,b int); 509 insert into t2 values ('{"t1":"a"}',1),('{"t1":"b"}',2); 510 select * from t2; 511 512 drop table if exists t3; 513 create table t3( 514 deptno varchar(20), 515 dname varchar(15), 516 loc varchar(50), 517 primary key(deptno) 518 ); 519 520 insert into t3 values (10,'ACCOUNTING','NEW YORK'); 521 insert into t3 values (20,'RESEARCH','DALLAS'); 522 insert into t3 values (30,'SALES','CHICAGO'); 523 insert into t3 values (40,'OPERATIONS','BOSTON'); 524 select * from t3; 525 526 drop table t3; 527 drop table t2; 528 529 drop snapshot if exists sp10; 530 create snapshot sp10 for account sys; 531 532 select count(*) from t3{snapshot = 'sp10'}; 533 select count(*) from t2{snapshot = 'sp10'}; 534 select count(*) from t1{snapshot = 'sp10'}; 535 select * from t1{snapshot = 'sp10'}; 536 select * from t2{snapshot = 'sp10'}; 537 select * from t3{snapshot = 'sp10'}; 538 539 -- @ignore:0 540 select distinct(object_name) from metadata_scan('test07.t3','a')m; 541 -- @ignore:0 542 select distinct(object_name) from metadata_scan('test07.t2','a')m; 543 -- @ignore:0 544 select distinct(object_name) from metadata_scan('test07.t1','a')m; 545 drop table t1; 546 drop database test07; 547 drop snapshot sp10; 548 drop snapshot sp08; 549 550 551 552 553