Solved

Using mixed case for table and column names

Posted on 2008-10-17
9
1,241 Views
Last Modified: 2013-12-18
We're used to developing systems for MS-SQL, and our standards have grown up around using mixed case identifiers--tables and columns--as allowed in MS-SQL.  We have a new project that is using an Oracle back-end, and we're discovering that our standards don't play so well in the Oracle world.  Mixed-case seems to be allowed, but it seems that our queries will have to make extensive use of double-quotes to accommodate this.  

Can someone please summarize (or point me to) some current object naming standards for Oracle development work?  Thank you in advance!
0
Comment
Question by:roblinx
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 18

Assisted Solution

by:sventhan
sventhan earned 200 total points
Comment Utility
0
 
LVL 18

Assisted Solution

by:sventhan
sventhan earned 200 total points
Comment Utility
0
 

Author Comment

by:roblinx
Comment Utility
Hmm... these are helpful--thank you--but they don't seem to address the issue of letter case.  Have any more?  :-)
0
 
LVL 4

Accepted Solution

by:
hqassap earned 250 total points
Comment Utility

Hello,

You have to use double quotes  in the DDL statements (Create, Alter, and Drop) and in DML statements (Insert, Update, and Delete); further to the Select query statements.

Following examples show you that in some details:

ccc @ TNNGT2> CREATE TABLE "TEst" ("No" NUMBER(2), "NAme" VARCHAR2(20));

Table created.

ccc @ TNNGT2>
ccc @ TNNGT2> SELECT table_name
  2    FROM user_tables
  3   WHERE table_name = 'TEst';

TABLE_NAME
------------------------------
TEst

ccc @ TNNGT2>
ccc @ TNNGT2> SELECT table_name, column_name , data_type
  2    FROM user_tab_columns
  3   WHERE column_name IN ('No', 'NAme');

TABLE_NAME                     COLUMN_NAME                    DATA_TYPE
------------------------------ ------------------------------ -------------------------------------------
TEst                           No                             NUMBER
TEst                           NAme                           VARCHAR2

2 rows selected.

ccc @ TNNGT2>
ccc @ TNNGT2> INSERT INTO "TEst"
  2              ("No", "NAme")
  3       VALUES (1, 'ABC');

1 row created.

ccc @ TNNGT2>
ccc @ TNNGT2> COMMIT ;

Commit complete.

ccc @ TNNGT2>
ccc @ TNNGT2> SELECT *
  2    FROM "TEst";

        No NAme
---------- --------------------
         1 ABC

ccc @ TNNGT2>
ccc @ TNNGT2> DROP TABLE "TEst";

Table dropped.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 18

Expert Comment

by:sventhan
Comment Utility
Use UPPER, LOWER functions to handle the case for upper and lower.
0
 

Author Comment

by:roblinx
Comment Utility
Thanks guys... all very helpful!

What I'm looking for is opinions about best practices.  We had gotten it into our heads (thanks to MSSQL work) that all-caps is bad, and underscores were wasted space.  But... if Oracle requires the use of double-quotes to make use of mixed case for table and column names, perhaps it's not worth it.  

What do you do when developing applications for Oracle databases?  Mixed-case, or all caps?
0
 
LVL 4

Assisted Solution

by:hqassap
hqassap earned 250 total points
Comment Utility
Hi,

Find below link for Naming conventions for Oracle tables, columns, indexes:
http://www.gplivna.eu/papers/naming_conventions.htm

Also, you can use such Code formatters such as Formatter Plus (product of Quest)
0
 
LVL 23

Assisted Solution

by:David
David earned 50 total points
Comment Utility
Always upper case for object names such as tables and columns.  Data content may be whatever you want, provided you're willing to search on all case possibilities.  See sventhan's comment for a best practice to make your search string always one case, usually upper -- as in "SELECT ... WHERE UPPER(columnname) = "ALLCAP";
 
0
 

Author Comment

by:roblinx
Comment Utility
Thanks, experts, for your opinions and advice!

We ended up going against our MS-SQL background, using all-caps table and field names that employed underscores to separate words, where there was more than one word.  

Examples:

BUSINESS_FUNCTIONS
USER_DIVISION_XREF

DIVISION_ID
CREATED_BY

I spread the credit around, as I did read and benefit from your answers.  Thank you.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to recover a database from a user managed backup
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now