Wednesday, September 9, 2009

Writing SQL Statements

Writing SQL Statements :
  • SQL statements are not case-sensitive
  • SQL statements can be on one or more lines
  • Keywords cannot be abbreviated or split across lines
  • Clauses are usually placed on separate lines
  • Indents are used to enhance readability
  • In SQL Query Tool(PGADMIN3), SQL statements can optionally be terminated by a semicolon (;)
  • Semicolons are required if you execute multiple SQL statements
  • In PSQL Client, you are required to end each SQL statement with a semicolon (;)

Friday, September 4, 2009

SQL SELECT Statement

Capabilities of SQL SELECT Statements :



Basic SELECT Statement :
  • SELECT * | {[DISTINCT] column | expression [alias],...} FROM table;
  • SELECT identifies the columns to be displayed
  • FROM identifies the table containing those columns
  • * specifies Selecting All Columns
  • column name specifies : selecting Specific Columns
  • eg1 : postgres=# select*from dept; (will return the all the columns of table dept)
  • eg2 : edb=# select deptno, dname from dept; (will return the specific columns of table dept)

Followers