Oracle命名对象,Oracle、PostgreSQL的对象命名规则

Oracle命名规则

一、标准命名规则

标准命名规则要满足如下要求:

1.以字符开头

2.30个字符以内

3.只能包含A-Z,a-z,0-9,_,$,#

4.不能和同一个用户下的其他对象重名

5.不能是oracle服务器的保留关键字

二、非标准命名规则

还有一类是非标准命名,可以使用任何字符,包括中文,oracle中的保留字,空格等等都是可以的, 但是需要将对象名用双引号引起来。

例如: create table “table” (test1 varchar2(10));将会建立一个表名为table的表。

并没有什么语法错误。但这这样以后就需要以后在使用这个对象时必须用双引号经对象引起来。

非标准命名在后续使用中容易因为忽略双引号导致种种错误,如非必要,个人不建议使用。

PostgreSQL命名规则

一、标准命名规则

标准命名规则要满足如下要求:

1.SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_).

2.Subsequent characters in an identifier or key word can be letters(a-z), underscores(_), digits (0-9), or dollar signs ($).

Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable.

3.不能和同一个模式下的其他对象重名

4.不能是PostgreSQL关键字(注意不同对象的关键字不同)

5.The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard.

二、非标准命名规则

还有一类是非标准命名,可以使用任何字符,包括中文,PostgreSQL中的保留字,空格等等都是可以的。 但是需要将对象名用双引号引起来。并没有什么语法错误。但这这样以后就需要以后在使用这个对象时必须用双引号经对象引起来。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值