背景介绍
由于Oracle数据库默认是将列名以大写的形式存储的,LightDB数据库默认以小写的形式存储列名,为了兼容Oracle数据库的SQL语句,LightDB23.4版本支持双引号+字段名大写来操作以小写形式存储的列名。这个功能仅在Oracle兼容模式下生效,并且支持DML操作。
使用示例
- 建表,字段名
id
是小写的
powershell
lightdb@oracle_test=# create table t1(id int);
CREATE TABLE
lightdb@oracle_test=# \d+ t1
Table "public.t1"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
id | integer | | | | plain | |
Access method: heap
lightdb@oracle_test=#
- 插入数据,以
"ID"
的方式插入成功
powershell
lightdb@oracle_test=# insert into t1("ID") values(10),(20),(30);
INSERT 0 3
lightdb@oracle_test=#
lightdb@oracle_test=# select * from t1;
id
----
10
20
30
(3 rows)
lightdb@oracle_test=#
- 查找数据,以
"ID"
查找成功
powershell
lightdb@oracle_test=# select "ID" from t1;
ID
----
10
20
30
(3 rows)
lightdb@oracle_test=#
- 更新数据
powershell
lightdb@oracle_test=# update t1 set "ID"=25 where id = 20;
UPDATE 1
lightdb@oracle_test=# select "ID" from t1;
ID
----
10
30
25
(3 rows)
lightdb@oracle_test=#
- 删除数据
powershell
lightdb@oracle_test=# delete from t1 where "ID" = 25;
DELETE 1
lightdb@oracle_test=# select "ID" from t1;
ID
----
10
30
(2 rows)
lightdb@oracle_test=#