Sunday 28 September 2014

SELECT statement in Oracle

SELECT Statement retrieves information from database. Capabilities of SELECT statements are

  • Projection : Selection of columns.
  • Selection  :  Selection of rows. 
  • Join          :  Combining two or more tables columns.




Select all columns from table

Syntax : Select * from <table name>;
* keyword is used to get all columns from table.

Note: set pagesize and set linesize is used to display your result properly is sql*plus.

Select specific column from table

Syntax : Select <column_1, column_2, ...> from <table name>;

Arithmetic operation in select query 

You can perform arithmetic operation on numeric values. It is only used for display doesn't affect actual table. Arithmetic operation like addition, subtraction, multiplication and division can easily perform on each rows. 

Operator precedence in select query

Operator precedence works like simple operator precedence works in mathematics. 

if you want more specific separate your calculation in bracket. It has highest priority and calculation inside bracket execute first. 

Column name in select query


Column alias in select query

In your select query result you can alias the name of column. 

Column alias in inverted comma 

Space is not recognized in column alias until you use inverted comma. Ex. desig is define as employee desig with inverted comma. 

Concatenation operator in sql

Concatenation operator (||) simply concatenate different column values into single column. you can add desire text in it. 



Distinct keyword in sql

Distinct keywords remove duplicates values in result. It is useful command in some cases you may want to how many unique values your column contain at that time you can use distinct keyword. You can also apply distinct keyword on no of column. 


No comments:

Post a Comment