简体   繁体   English

Oracle区分大小写的格式SQL

[英]Oracle case sensitive Format SQL

I need to format SQL statement for Oracle Db. 我需要格式化Oracle Db的SQL语句。 I have a sql statement and I don't want to change the case. 我有一条sql语句,但我不想更改大小写。 For Eg. 例如

CREATE TABLE DPAuditTrailDetail
(
   ID               NUMBER (19, 0) DEFAULT 0 NOT NULL,
   AuditTrail       NUMBER (19, 0) DEFAULT 0 NOT NULL,
   sysObjectField   NUMBER (19, 0) DEFAULT 0 NOT NULL,
   OldValue         NCLOB DEFAULT NULL ,
   NewValue         NCLOB DEFAULT '' NOT NULL,
   Referenced       NUMBER (19, 0) DEFAULT NULL
);

I believe, to create table with this table name and column names in oracle, i will have to add double quotes("") to each name. 我相信,要在oracle中使用此表名和列名创建表,我将必须对每个名称添加双引号(“”)。 I have a big script and I would like to do it as quick as possible. 我的脚本很大,我想尽快完成。

Please do suggest some quick way to do it. 请提出一些快速的方法。

Thanks. 谢谢。

Just use the CREATE statement as-is. 只需按原样使用CREATE语句即可。 The tables will be created so that all the following will work just fine: 将创建表,以便所有以下各项正常工作:

select AuditTrail from DPAuditTrailDetail where ID=1;

select AUDITTRAIL from DPAUDITTRAILDETAIL where ID=1;

select aUdITtraIL from dpaudittraildetaiL where id=1;

Oracle queries are case-insensitive by default and your life (and that of those maintaining your code when you're gone) will be easier if you stick to this default. Oracle查询默认情况下不区分大小写,如果您坚持使用此默认值,您的生活(以及离开后维护代码的工作)将变得更加轻松。

If you really have to use case-sensitive table/column names, the only way is to add double-quotes to table/column names. 如果确实必须使用区分大小写的表/列名称,则唯一的方法是在表/列名称中添加双引号。 But as the commenters said, it's not good practice to use case-sensitive names 但是正如评论者所说,使用区分大小写的名称不是一个好习惯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM