github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/ddl/lowercase.test (about)

     1  -- lower case sensitivity
     2  -- DEFAULT:1
     3  
     4  -- DB_name
     5  DROP DATABASE IF EXISTS TEST01;
     6  CREATE DATABASE TEST01;
     7  show CREATE DATABASE test01;
     8  DROP DATABASE test01;
     9  
    10  -- DB_name
    11  DROP DATABASE IF EXISTS test02;
    12  CREATE DATABASE test02;
    13  show CREATE DATABASE TEST02;
    14  DROP DATABASE test02;
    15  
    16  -- mixed uppercase
    17  DROP DATABASE IF EXISTS mysql_TEST;
    18  CREATE DATABASE mysql_TEST;
    19  show CREATE DATABASE mysql_TEST;
    20  DROP DATABASE mysql_TEST;
    21  
    22  -- TEMPORARY table
    23  DROP DATABASE IF EXISTS test03;
    24  DROP TABLE IF EXISTS t1;
    25  CREATE DATABASE test03;
    26  USE test03;
    27  CREATE TEMPORARY TABLE t1(a float);
    28  INSERT INTO T1 VALUES(213823.12);
    29  INSERT INTO t1 VALUES(-45412.38920);
    30  SELECT * FROM t1;
    31  DROP TABLE T1;
    32  
    33  -- external table
    34  drop table IF EXISTS table01;
    35  CREATE external table table01(clo1 int,clo2 bigint)infile{"filepath"='$resources/external_table_file/aaa.csv'} fields terminated by ',';
    36  SELECT * FROM Table01;
    37  SELECT Clo1 FROM table01;
    38  DROP table table01;
    39  
    40  -- Table name
    41  DROP TABLE IF EXISTS t1;
    42  CREATE TABLE t1(id int PRIMARY KEY, Word VARCHAR(40) NOT NULL, INDEX(Word));
    43  show CREATE TABLE t1;
    44  INSERT INTO t1 VALUES (1, 'a');
    45  INSERT INTO t1 VALUES (2, 'b');
    46  INSERT INTO t1 VALUES (3, 'c');
    47  INSERT INTO T1 VALUES (4, 'd');
    48  
    49  SELECT * FROM t1;
    50  SELECT * FROM T1;
    51  SELECT T1.id FROM T1 LIMIT 1;
    52  SELECT T1.id FROM t1 LIMIT 1;
    53  SELECT id FROM T1;
    54  select ID FROM t1;
    55  SELECT Id FROM t1;
    56  SELECT COUNT(*) FROM t1;
    57  SELECT COUNT(*) FROM T1;
    58  SELECT COUNT(t1.id) FROM t1;
    59  SELECT COUNT(T1.Id) FROM t1;
    60  SELECT * FROM t1 WHERE Id = 2;
    61  
    62  DROP TABLE IF EXISTS t2;
    63  CREATE table t2(id int PRIMARY KEY, Word VARCHAR(40) NOT NULL, INDEX(Word));
    64  INSERT INTO T2 SELECT * from T1;
    65  SELECT * FROM T2;
    66  DROP TABLE t1;
    67  
    68  DROP TABLE IF EXISTS t2;
    69  DROP TABLE IF EXISTS t3;
    70  CREATE TABLE T2(id int PRIMARY KEY, Word VARCHAR(40) NOT NULL, INDEX(Word));
    71  CREATE TABLE t3(id int primary key, Word varchar(40) NOT NULL);
    72  show CREATE TABLE t2;
    73  show CREATE TABLE t3;
    74  INSERT INTO T2 VALUES (1, 'a');
    75  INSERT INTO t2 VALUES (2, 'b');
    76  INSERT INTO t2 VALUES (3, 'c');
    77  INSERT INTO T2 VALUES (4, 'd');
    78  INSERT INTO t3 VALUES (1,'match');
    79  DELETE FROM t2 WHERE id = 1;
    80  DELETE FROM T2 WHERE ID = 2;
    81  
    82  SELECT * FROM T2;
    83  SELECT * FROM t3;
    84  
    85  SELECT T2.id FROM T2 LIMIT 1;
    86  SELECT Id, WORD FROM t2;
    87  SELECT * FROM t3 WHERE WORD = 'match';
    88  
    89  -- Alias case sensitive
    90  SELECT t3.id AS t3_ID FROM T3 LIMIT 1;
    91  SELECT t3.ID AS t3_ID FROM t3 LIMIT 1;
    92  
    93  SELECT * FROM t2 left join t3 ON (test.t2.id= TEST.t3.id) WHERE t2.id >= t3.id;
    94  DROP TABLE t2;
    95  DROP TABLE t3;
    96  
    97  -- foreign key
    98  DROP TABLE IF EXISTS t4;
    99  DROP TABLE IF EXISTS t5;
   100  CREATE TABLE t4(a int primary key,b varchar(5));
   101  CREATE TABLE t5(a int ,b varchar(5), C int, constraint fc foreign key(C) references t4(a));
   102  ALTER table t5 DROP FOREIGN KEY fC;
   103  ALTER table t5 ADD constraint fC foreign key(c) REFERENCES t4(a);
   104  show CREATE TABLE t4;
   105  show CREATE TABLE T5;
   106  DROP table t5;
   107  DROP table t4;
   108  
   109  -- create USER
   110  DROP USER IF EXISTS u_name;
   111  CREATE USER u_name IDENTIFIED BY '123456';
   112  CREATE USER U_NAME IDENTIFIED BY '123456';
   113  CREATE USER U_name IDENTIFIED BY '123456';
   114  SELECT user_host,user_name,status FROM mo_catalog.mo_user WHERE user_name = 'U_name';
   115  SELECT user_host,user_name,status FROM mo_catalog.mo_user;
   116  DROP USER u_name;
   117  DROP DATABASE test03;
   118  
   119  -- Test all caps database name
   120  DROP database IF EXISTS test03;
   121  create database test03;
   122  use test03;
   123  create table t6 (a int);
   124  INSERT INTO t6 VALUES(1);
   125  INSERT INTO t6 VALUES(24845615);
   126  INSERT INTO T6 VALUES(-289173);
   127  select T6.a from test03.T6;
   128  select t6.a from test03.T6;
   129  select test03.t6.a from TEST03.t6;
   130  select TEST03.t6.a from TEST03.t6;
   131  select TEST03.T6.a from TEST03.T6;
   132  select TEST03.T6.a from T6;
   133  select TEST03.t6.a from TEST03.t6;
   134  DROP TABLE t6;
   135  
   136  -- multiupdate/delete & --lower-case-table-names
   137  DROP TABLE IF EXISTS t7;
   138  DROP TABLE IF EXISTS t8;
   139  create table t7 (a int);
   140  create table t8 (a int);
   141  INSERT INTO t7 VALUES(1);
   142  INSERT INTO t8 VALUES(1);
   143  update t7 as p1, t8 as p2 SET p1.a=1,p2.a=1 where p1.a=p2.a;
   144  update t7 as P1, t8 as P2 SET P1.a=10,p2.a=100 where P1.a=p2.a;
   145  SELECT * FROM t7;
   146  SELECT * FROM t8;
   147  DROP TABLE t7;
   148  DROP TABLE t8;
   149  drop database test03;
   150  
   151  -- aliases case insensitive
   152  DROP DATABASE IF EXISTS test04;
   153  CREATE DATABASE test04;
   154  USE test04;
   155  DROP table IF EXISTS t9;
   156  DROP table IF EXISTS t10;
   157  CREATE TABLE t9 (a int);
   158  CREATE TABLE t10(a int);
   159  INSERT INTO t9 VALUES(100);
   160  INSERT INTO t10 VALUES(1000);
   161  SELECT t9.a AS a,t10.A as B from t9,t10;
   162  DROP TABLE t9;
   163  DROP TABLE t10;
   164  
   165  -- index(PRIMARY KEY, UNIQUE index, index)
   166  DROP TABLE if EXISTS t10;
   167  create table t10(id int PRIMARY KEY,name VARCHAR(255),age int);
   168  insert into t10 values(1,"Abby", 24);
   169  insert into t10 values(2,"Bob", 25);
   170  create unique index idx on t10(name);
   171  select * from t10;
   172  show CREATE TABLE t10;
   173  DROP TABLE t10;
   174  
   175  DROP table IF EXISTS t11;
   176  CREATE table t11(col1 int PRIMARY KEY,col2 CHAR,col3 float);
   177  INSERT INTO t11 VALUES(1,'a',898021.8392);
   178  INSERT INTO t11 VALUES(2, NULL, 213145.45);
   179  select * from t11;
   180  show CREATE table t11;
   181  DROP TABLE t11;
   182  
   183  DROP TABLE IF EXISTS t12;
   184  CREATE TABLE t12(col1 int,col2 varchar(20),col3 double);
   185  CREATE INDEX ABc ON t12(col2);
   186  DROP INDEX abc on t12;
   187  select * from t12;
   188  show CREATE table t12;
   189  DROP TABLE t12;
   190  
   191  -- create account
   192  DROP ACCOUNT IF EXISTS tenant_test;
   193  CREATE ACCOUNT tenant_test admin_name = 'root' identified by '111' open comment 'tenant_test';
   194  ALTER ACCOUNT tenant_TEST comment 'abcddddddfsfafaffsefsfsefljofiseosfjosisssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss24444444444444444444444444222222222@fffffffffffffffffffffffffffffffffffffffffffffffffffff';
   195  CREATE ACCOUNT tenant_TEST admin_name = 'root' identified by '111' open comment 'tenant_test';
   196  CREATE ACCOUNT TENANT_TEST admin_name = 'root' identified by '111' open comment 'tenant_test';
   197  SELECT account_name,status,comments FROM mo_catalog.mo_account WHERE account_name = 'tenant_test';
   198  DROP ACCOUNT IF EXISTS TENANT_TEST;
   199  
   200  
   201  -- create role
   202  DROP ROLE IF EXISTS rolex;
   203  CREATE ROLE rolex;
   204  CREATE ROLE Rolex;
   205  CREATE ROLE ROLEX;
   206  SELECT role_name,COmments FROM mo_catalog.mo_role;
   207  SELECT role_name,COmments FROM mo_catalog.mo_role WHERE role_name = 'Rolex';
   208  DROP ROLE rolex;
   209  
   210  -- create sequence
   211  DROP SEQUENCE IF EXISTS SEQ;
   212  CREATE SEQUENCE SEQ increment 100 start 30;
   213  CREATE SEQUENCE seq increment 100 start 30;
   214  SELECT * FROM SEQ;
   215  SELECT laSt_seq_nuM,min_value,start_value FROM Seq;
   216  DROP SEQUENCE SEQ;
   217  
   218  -- create view
   219  DROP TABLE IF EXISTS t12;
   220  DROP TABLE IF EXISTS t13;
   221  DROP view IF EXISTS view1;
   222  CREATE TABLE t12(a INTEGER);
   223  INSERT INTO t12 VALUES (1),(2);
   224  CREATE TABLE t13(a INTEGER);
   225  INSERT INTO t13 VALUES (1);
   226  CREATE VIEW view1 AS SELECT t12.a, t13.a AS b FROM t12 LEFT JOIN t13 USING(a);
   227  CREATE VIEW VIEW1 AS SELECT t12.a, t13.a AS b FROM t12 LEFT JOIN t13 USING(a);
   228  DROP VIEW view1;
   229  DROP TABLE t12;
   230  DROP TABLE t13;
   231  
   232  -- drop view
   233  DROP TABLE IF EXISTS TaB;
   234  DROP VIEW IF EXISTS vie;
   235  CREATE TABLE TaB(Field int);
   236  CREATE VIEW ViE AS SELECT * FROM TAb;
   237  show CREATE TABLE VIe;
   238  DROP VIEW vie;
   239  DROP table TAB;
   240  
   241  -- alter view
   242  DROP TABLE IF EXISTS t13;
   243  DROP VIEW IF EXISTS view01;
   244  CREATE TABLE t13 (a int);
   245  INSERT INTO t13 VALUES(1),(2),(3),(4);
   246  CREATE VIEW view01 AS SELECT * FROM t13;
   247  ALTER VIEW VIEW01 AS SELECT * FROM t13 WHERE a=1 or a = 2;
   248  show CREATE TABLE vieW01;
   249  SELECT * FROM view01;
   250  SELECT * FROM vieW01 WHERE A = 1 OR a = 2;
   251  DROP view view01;
   252  drop table t13;
   253  drop database test04;
   254  
   255  -- with symbol ``,DB_name
   256  DROP DATABASE IF EXISTS `TEST01`;
   257  CREATE DATABASE `TEST01`;
   258  show CREATE DATABASE `test01`;
   259  DROP DATABASE `test01`;
   260  
   261  -- with symbol ``,DB_name
   262  DROP DATABASE IF EXISTS `test02`;
   263  CREATE DATABASE `test02`;
   264  show CREATE DATABASE `TEST02`;
   265  DROP DATABASE `test02`;
   266  
   267  -- with symbol ``,mixed uppercase
   268  DROP DATABASE IF EXISTS `mysql_TEST`;
   269  CREATE DATABASE `mysql_TEST`;
   270  show CREATE DATABASE `mysql_TEST`;
   271  DROP DATABASE `mysql_TEST`;
   272  
   273  -- with symbol ``
   274  DROP DATABASE IF EXISTS `test05`;
   275  CREATE DATABASE `test05`;
   276  use `Test05`;
   277  CREATE TABLE `t11`(aa float);
   278  INSERT INTO `t11` VALUES(12.322);
   279  INSERT INTO `T11` VALUES(-56.23);
   280  SELECT * FROM `t11`;
   281  DROP table t11;
   282  
   283  -- with symbol ``,Test all caps database name
   284  DROP TABLE IF EXISTS `t12`;
   285  create table `t12` (a int);
   286  INSERT INTO `t12` VALUES(1);
   287  INSERT INTO `t12` VALUES(24845615);
   288  INSERT INTO `T12` VALUES(-289173);
   289  select `T12`.a from `test05`.T12;
   290  select `t12`.a from `test05`.T12;
   291  select test05.t12.a from `TEST05`.t12;
   292  select `TEST05`.t12.a from TEST05.t12;
   293  select TEST05.T12.a from TEST05.`T12`;
   294  select TEST05.T12.a from `T12`;
   295  select TEST05.t12.a from `TEST05`.t12;
   296  DROP TABLE t12;
   297  DROP DATABASE TEST05;
   298  
   299  -- with symbol ``,aliases case insensitive
   300  DROP DATABASE IF EXISTS `test06`;
   301  CREATE DATABASE `test06`;
   302  USE test06;
   303  DROP table IF EXISTS `t13`;
   304  DROP table IF EXISTS `t14`;
   305  CREATE TABLE `t13` (a int);
   306  CREATE TABLE `t14` (a int);
   307  INSERT INTO `t13` VALUES(100);
   308  INSERT INTO `t14` VALUES(1000);
   309  SELECT `t13`.a AS a,`t14`.A as B from `t13`,`t14`;
   310  DROP TABLE `t13`;
   311  DROP TABLE `t14`;
   312  
   313  -- with symbol ``,multiupdate/delete & --lower-case-table-names
   314  DROP TABLE IF EXISTS `t15`;
   315  DROP TABLE IF EXISTS `t16`;
   316  create table `t15` (a int);
   317  create table `t16` (a int);
   318  INSERT INTO `t15` VALUES(1);
   319  INSERT INTO `t16` VALUES(1);
   320  update `t15` as p1, `t16` as p2 SET p1.a=1,P2.a=1 where p1.a=P2.a;
   321  update `t15` as P1, `t16` as P2 SET P1.a=10,p2.a=100 where P1.a=p2.a;
   322  SELECT * FROM `t15`;
   323  SELECT * FROM `T16`;
   324  DROP TABLE `t15`;
   325  DROP TABLE `t16`;
   326  
   327  -- with symbol ``,index(PRIMARY KEY, UNIQUE index, index)
   328  DROP TABLE if EXISTS `t17`;
   329  create table `t17`(id int PRIMARY KEY,name VARCHAR(255),age int);
   330  insert into `t17` values(1,"Abby", 24);
   331  insert into `t17` values(2,"Bob", 25);
   332  create unique index `Idx` on t17(name);
   333  select * from `t17`;
   334  show CREATE TABLE `t17`;
   335  DROP TABLE `t17`;
   336  
   337  -- with symbol ``, create sequence
   338  DROP SEQUENCE IF EXISTS `SEQ`;
   339  CREATE SEQUENCE `SEQ` increment 100 start 30;
   340  CREATE SEQUENCE `seq` increment 100 start 30;
   341  SELECT * FROM `SEQ`;
   342  SELECT `laSt_seq_nuM`,`min_value`,`start_value` FROM Seq;
   343  DROP SEQUENCE `SEQ`;
   344  
   345  DROP table IF EXISTS `t18`;
   346  CREATE table `t18`(col1 int PRIMARY KEY,col2 CHAR,col3 float);
   347  INSERT INTO `t18` VALUES(1,'a',898021.8392);
   348  INSERT INTO `t18` VALUES(2, NULL, 213145.45);
   349  select * from `t18`;
   350  show CREATE table `t18`;
   351  DROP TABLE `t18`;
   352  
   353  DROP TABLE IF EXISTS `t19`;
   354  CREATE TABLE `t19`(col1 int,col2 varchar(20),col3 double);
   355  CREATE INDEX `ABc` ON t19(col2);
   356  DROP INDEX `abc` ON t19;
   357  select * from `t19`;
   358  show CREATE table `t19`;
   359  DROP TABLE `t19`;
   360  
   361  -- create account
   362  DROP ACCOUNT IF EXISTS `tenant_test`;
   363  CREATE ACCOUNT `tenant_test` admin_name = 'root' identified by '111' open comment 'tenant_test';
   364  ALTER ACCOUNT `tenant_TEST` comment 'abcddddddfsfafaffsefsfsefljofiseosfjosisssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss24444444444444444444444444222222222@fffffffffffffffffffffffffffffffffffffffffffffffffffff';
   365  CREATE ACCOUNT `tenant_TEST` admin_name = 'root' identified by '111' open comment 'tenant_test';
   366  CREATE ACCOUNT `TENANT_TEST` admin_name = 'root' identified by '111' open comment 'tenant_test';
   367  SELECT `account_name`,`status`,`comments` FROM `mo_catalog`.`mo_account` WHERE `account_name` = 'tenant_test';
   368  DROP ACCOUNT IF EXISTS TENANT_TEST;
   369  
   370  -- create role
   371  DROP ROLE IF EXISTS `rolex`;
   372  CREATE ROLE `rolex`;
   373  CREATE ROLE `Rolex`;
   374  CREATE ROLE `ROLEX`;
   375  SELECT role_name,comments FROM `mo_catalog`.`mo_role`;
   376  SELECT role_name,COmments FROM `mo_catalog`.`mo_role` WHERE `role_name` = 'Rolex';
   377  DROP ROLE `Rolex`;
   378  
   379  -- create USER
   380  DROP USER IF EXISTS `user_name`;
   381  CREATE USER `user_name` IDENTIFIED BY '123456';
   382  CREATE USER `USER_NAME` IDENTIFIED BY '123456';
   383  CREATE USER `USER_name` IDENTIFIED BY '123456';
   384  SELECT `user_host`,`user_name`,`status` FROM `mo_catalog`.`mo_user`;
   385  SELECT `user_host`,`user_name`,`status` FROM `mo_catalog`.`mo_user` WHERE user_name = 'User_name';
   386  DROP USER `user_name`;
   387  DROP DATABASE `test06`;
   388  
   389  -- create view
   390  drop database if exists `test10`;
   391  create database `test10`;
   392  use `test10`;
   393  DROP TABLE IF EXISTS `t20`;
   394  DROP TABLE IF EXISTS `t21`;
   395  DROP VIEW IF EXISTS `view1`;
   396  CREATE TABLE `t20`(a INTEGER);
   397  INSERT INTO `t20` VALUES (1),(2);
   398  CREATE TABLE `t21`(a INTEGER);
   399  INSERT INTO `t21` VALUES (1);
   400  CREATE VIEW `view1` AS SELECT t20.a, T21.a AS b FROM t20 LEFT JOIN t21 USING(a);
   401  CREATE VIEW `VIEW1` AS SELECT t20.a, t21.a AS b FROM t20 LEFT JOIN t21 USING(a);
   402  SELECT * FROM `view1`;
   403  DROP VIEW `view1`;
   404  DROP TABLE `t20`;
   405  DROP TABLE `t21`;
   406  
   407  -- DROP view
   408  DROP TABLE IF EXISTS `TaB`;
   409  DROP VIEW IF EXISTS `ViE`;
   410  CREATE TABLE `TaB`(Field int);
   411  INSERT INTO TAB VALUES(10);
   412  CREATE VIEW `ViE` AS SELECT * FROM `TAb`;
   413  show CREATE TABLE `VIe`;
   414  DROP view `VIE`;
   415  DROP table `TAB`;
   416  
   417  -- alter view
   418  DROP TABLE IF EXISTS `t22`;
   419  DROP VIEW IF EXISTS `view01`;
   420  CREATE TABLE `t22` (a int);
   421  INSERT INTO `t22` VALUES(1),(2),(3),(4);
   422  CREATE VIEW `view01` AS SELECT * FROM `t22`;
   423  ALTER VIEW `VIEW01` AS SELECT * FROM `t22` WHERE a=1;
   424  SELECT * FROM `view01`;
   425  SELECT * FROM `view01` WHERE A = 1;
   426  DROP view `vieW01`;
   427  drop database if exists `test10`;
   428  
   429  -- TEMPORARY table
   430  DROP DATABASE IF EXISTS `test07`;
   431  DROP TABLE IF EXISTS `t1`;
   432  CREATE DATABASE `test07`;
   433  USE `test07`;
   434  CREATE TEMPORARY TABLE `t1`(a float);
   435  INSERT INTO `T1` VALUES(213823.12);
   436  INSERT INTO `t1` VALUES(-45412.38920);
   437  SELECT * FROM `t1`;
   438  DROP TABLE `t1`;
   439  DROP DATABASE `TEST07`;
   440  
   441  -- foreign key
   442  drop database if exists `test11`;
   443  create database `test11`;
   444  use `test11`;
   445  DROP TABLE IF EXISTS `t4`;
   446  DROP TABLE IF EXISTS `t5`;
   447  CREATE TABLE `t4`(a int primary key,b varchar(5));
   448  CREATE TABLE `t5`(a int ,b varchar(5), C int, constraint fc foreign key(C) references t4(a));
   449  ALTER table `t5` DROP FOREIGN KEY fC;
   450  ALTER table `t5` ADD constraint fC foreign key(c) REFERENCES t4(a);
   451  show CREATE TABLE `t4`;
   452  show CREATE TABLE `T5`;
   453  DROP table `t5`;
   454  DROP table `t4`;
   455  drop database if exists `test11`;
   456  
   457  -- external table
   458  DROP DATABASE IF EXISTS `test08`;
   459  CREATE DATABASE `test08`;
   460  use  `test08`;
   461  DROP table IF EXISTS `table02`;
   462  CREATE external table `table02`(clo1 int,clo2 bigint)infile{"filepath"='$resources/external_table_file/aaa.csv'} fields terminated by ',';
   463  SELECT * FROM `Table02`;
   464  drop table table02;
   465  DROP DATABASE `TEST08`;