功能简介
从LightDB 23.3版本开始mysql兼容模式支持lower_case_table_names功能(table和view名称支持大小写敏感)。
使用createdb
命令和create database
语句创建数据库时,可以指定参数来设置是否开启大小写敏感功能。
- createdb命令
createdb mysqltest --compatible-type=mysql --mysql-lower-case=0;
mysql-lower-case 取值范围为1,true,on,0,false,off,默认值是1。
0/false/off:开启大小写敏感的功能;
1/true/on:关闭大小写敏感的功能; - create database语句
create database mysqltest lightdb_syntax_compatible_type mysql lightdb_mysql_lower_case_table_names 0;
lightdb_mysql_lower_case_table_names 取值范围为1,true,on,0,false,off,默认值是1。
0/false/off:开启大小写敏感的功能;
1/true/on:关闭大小写敏感的功能;
使用说明
- 已create database语句为例,创建名称大小写敏感的数据库。
lightdb@postgres=# create database mysqltest lightdb_syntax_compatible_type mysql lightdb_mysql_lower_case_table_names 0;
CREATE DATABASE
lightdb@postgres=# \c mysqltest
You are now connected to database "mysqltest" as user "lightdb".
compatible type: mysql
lightdb@mysqltest=# create table t1(id int);
CREATE TABLE
lightdb@mysqltest=# create table T1(id int);
CREATE TABLE
lightdb@mysqltest=# \d
List of relations
Schema | Name | Type | Owner
------------+--------------------------------------+----------+---------
lt_catalog | lt_deps_saved_ddl | table | lightdb
lt_catalog | lt_sm_key_ext_stat | table | lightdb
lt_catalog | lt_sm_key_stat | table | lightdb
lt_catalog | lt_stat_activity | view | lightdb
lt_catalog | pg_buffercache | view | lightdb
lt_catalog | pg_show_plans | view | lightdb
lt_catalog | pg_stat_statements | view | lightdb
lt_catalog | sample_active_session_history | table | lightdb
lt_catalog | sample_active_session_history_id_seq | sequence | lightdb
lt_catalog | sample_active_session_profile | table | lightdb
lt_catalog | sample_active_session_profile_id_seq | sequence | lightdb
lt_catalog | sample_activity_history | table | lightdb
lt_catalog | sample_activity_history_id_seq | sequence | lightdb
lt_catalog | sample_activity_profile | table | lightdb
lt_catalog | sample_activity_profile_id_seq | sequence | lightdb
mysql | dual | view | lightdb
public | T1 | table | lightdb
public | t1 | table | lightdb
(18 rows)
lightdb@mysqltest=#
- 操作创建出来的表。
lightdb@mysqltest=# insert into t1 values(1),(2),(3);
INSERT 0 3
lightdb@mysqltest=#
lightdb@mysqltest=# insert into T1 values(100),(200),(300);
INSERT 0 3
lightdb@mysqltest=#
lightdb@mysqltest=# select * from t1;
id
----
1
2
3
(3 rows)
lightdb@mysqltest=#
lightdb@mysqltest=# select * from T1;
id
-----
100
200
300
(3 rows)
lightdb@mysqltest=#