github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/snapshot/snapshot_restore_table_with_fk.sql (about)

     1  create account acc1 ADMIN_NAME 'admin1' IDENTIFIED BY 'test123';
     2  
     3  -- @session:id=2&user=acc1:admin1&password=test123
     4  show databases;
     5  create database fk_test;
     6  use fk_test;
     7  create table t1 (a int primary key);
     8  insert into t1 values (1);
     9  create table t2 (a int primary key, b int, FOREIGN KEY (b) REFERENCES t2(a));
    10  insert into t2 values (1, 1);
    11  create table t3 (a int primary key, b int unique key, FOREIGN KEY (a) REFERENCES t1(a), FOREIGN KEY (b) REFERENCES t2(a));
    12  insert into t3 values (1, 1);
    13  create table t4 (a int primary key, b int, FOREIGN KEY (b) REFERENCES t3(b));
    14  insert into t4 values (2, 1);
    15  create table t5 (a int, FOREIGN KEY (a) REFERENCES t4(a));
    16  insert into t5 values (2);
    17  create table t6 (a int, FOREIGN KEY (a) REFERENCES t4(a));
    18  insert into t6 values (2);
    19  
    20  show full tables;
    21  desc t1;
    22  desc t2;
    23  desc t3;
    24  desc t4;
    25  desc t5;
    26  desc t6;
    27  select * from t1;
    28  select * from t2;
    29  select * from t3;
    30  select * from t4;
    31  select * from t5;
    32  select * from t6;
    33  
    34  create snapshot sn1 for account acc1;
    35  -- @ignore:1
    36  show snapshots;
    37  
    38  drop database fk_test;
    39  restore account acc1 from snapshot sn1;
    40  
    41  show databases;
    42  use fk_test;
    43  show full tables;
    44  desc t1;
    45  desc t2;
    46  desc t3;
    47  desc t4;
    48  desc t5;
    49  desc t6;
    50  select * from t1;
    51  select * from t2;
    52  select * from t3;
    53  select * from t4;
    54  select * from t5;
    55  select * from t6;
    56  
    57  drop snapshot sn1;
    58  drop database fk_test;
    59  -- @session
    60  
    61  drop account acc1;