PG(HGDB)里创建表时不校验列名关键字

本文探讨了在PG(HGDB)数据库中创建表时列名关键字不受限制的现象,与Oracle数据库进行对比。在Oracle中,使用特定关键字作为列名可能会导致错误,但在PG(HGDB)中则允许,揭示了两者在数据库设计上的差异。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Oracle数据库现象:

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
SQL> create table a(table int);
create table a(table int)
               *
ERROR at line 1:
ORA-00904: : invalid identifier

SQL> create table a(column int);
create table a(column int)
               *
ERROR at line 1:
ORA-00904: : invalid identifier

Oracle中使用关键字作为列名时,字段需加双引号:
SQL> create table a("column" int);
Table created.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

HGDB现象:

highgo=# select version();
              version               
------------------------------------
 HighGo Database 3.1.4 Linux 64-bit
(1 row)
highgo=# create table a(relation int);
CREATE TABLE
highgo=# create table c(tuple int);
CREATE TABLE
highgo=# \d a
        Table "public.a"
  Column  |  Type   | Modifiers 
----------+---------+-----------
 relation | integer | 


highgo=# \d b
        Table "public.b"
  Column  |  Type   | Modifiers 
----------+---------+-----------
 relation | integer | 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值