views:

158

answers:

2

Dears,

I need to format SQL statement for Oracle Db. I have a sql statement and I don't want to change the case. 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. 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.

+1  A: 

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

zürigschnäzlets
+2  A: 

Just use the CREATE statement as-is. 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.

Nick Pierpoint
@hhk999: This is correct, if you leave out the quotes and the OR mapper tries to execute "DROP TABLE DPAuditTrailDetail" it will succeed.
wweicker