Solved

Using mixed case for table and column names

Posted on 2008-10-17
9
1,294 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
ID: 22744973
0
 
LVL 18

Assisted Solution

by:sventhan
sventhan earned 200 total points
ID: 22744978
0
 

Author Comment

by:roblinx
ID: 22745016
Hmm... these are helpful--thank you--but they don't seem to address the issue of letter case.  Have any more?  :-)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
hqassap earned 250 total points
ID: 22747509

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
 
LVL 18

Expert Comment

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

Author Comment

by:roblinx
ID: 22748232
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
ID: 22751300
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
ID: 22792681
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
ID: 22797797
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
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.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

762 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