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?
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
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.
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.