Wednesday, September 16, 2009

Limit the rows that are retrieved by a query

Limiting Rows Using a Selection :
  • Restrict the rows that are returned by using the WHERE clause
  • The WHERE clause follows the FROM clause
  • SELECT *|{[DISTINCT] column|expression [alias],...} FROM table [WHERE condition(s)];
  • eg : select*from emp where deptno=10;
Character Strings and Dates :
  • Character strings and date values are enclosed by single quotation marks
  • Character values are case-sensitive, and date values are format-sensitive
  • eg : select*from emp where ename='CLARK';

Sunday, September 13, 2009

Important Meta Commands in PostgreSQL

\c database name [username]
  • to connect to a database
\l
  • will return you the list of available databases
\du
  • will return you the list of databases users
\dt
  • will return you the list of tables in connected database
\d table name
  • will returns you the structure of the given table
\e
  • opens the sql query in editor or opens an editor to write query
show port
  • will returns you the port no on which postgres is running

few notations which are supposed to use while parsing these inputs :
  • -d : database name
  • -U : User name
  • -h : Host name
  • -p : Port No.
  • -f : File name (sql)
  • -w : Password

Followers