If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Capitalize Data Types?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-30-11, 13:04
CarlosinFL CarlosinFL is offline
Registered User
 
Join Date: Oct 2010
Location: Orlando, FL
Posts: 184
Question Capitalize Data Types?

I know it's common procedure when typing / documenting ANSI SQL to capitalize statements like 'SELECT', 'INSERT', 'DROP', 'UPDATE', & 'LIKE', however my question is what about data types? Is it recommended to capitalize data types in my code or leave them lowercase?

Code:
CREATE TABLE employees
(
emp_id integer PRIMARY KEY NOT NULL,
fname varchar(20) NOT NULL,
lname varchar(20) NOT NULL,
email varchar(50) UNIQUE NOT NULL,
dob date NOT NULL,
salary decimal(19,4) NULL,
city varchar(40) NOT NULL,
state char(2) NOT NULL
);
Reply With Quote
  #2 (permalink)  
Old 12-30-11, 13:21
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Do whatever you prefer, but be consistent - and document it.

Style depends a lot on the DBMS as well. In the PostgreSQL world, people tend to write everything in lowercase. In the Oracle world, people tend to write everything in uppercase and in the Microsoft world peopel tend to use CamelCase.
Reply With Quote
  #3 (permalink)  
Old 02-05-12, 11:30
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,191
Why do you worry to capitalize datatypes?
You also capitalized other keywords than statements, like 'TABLE', 'PRIMARY KEY', 'UNIQUE', 'NOT NULL', 'NULL'.

I prefer to capitalize keywords used to construct SQL statements(including built-in functions, attributes, options, so on),
and use all lowercases for others(user supplied resource names including user-defined-functions), even if that were compound words.

And, I prefer to use under score to separate each words in a compound word.
For example, I prefer to use employee_id than EmployeeId or EmployeeID.
Because, all of employee_id, Employee_Id, Employee_ID, EMPLOYEE_ID would be treated as same thing in SQL.
Reply With Quote
  #4 (permalink)  
Old 02-05-12, 11:37
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Quote:
Originally Posted by tonkuma View Post
Because, all of employee_id, Employee_Id, Employee_ID, EMPLOYEE_ID would be treated as same thing in SQL.
Not necessarily with MySQL or SQL Server. They can be case sensitive even without using double quotes.
Reply With Quote
  #5 (permalink)  
Old 02-05-12, 11:46
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,191
Quote:
Originally Posted by shammat View Post
Not necessarily with MySQL or SQL Server. They can be case sensitive even without using double quotes.
I think that I see the reason of you worte "Style depends a lot on the DBMS as well".
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On