SELECT Statement in Oracle

The SELECT statement in Oracle is used to retrieve data from tables, views, materialized views and object tables.

SELECT Statement

Syntax

SELECT expression
  FROM [schema_name.]table_name
 WHERE condition_1
   AND condition_2;
Parameters Explanation

schema_name

  • Name of the schema to which the table belongs. It is optional.

table_name

  • Name of the table from which you want to fetch data. It is mandatory.

condition_1, condition_2

  • Condition_1, condition_2 etc. filters the query data.

expression

  • An expression denotes a single column, multiple columns, standard functions or calculations that you want to fetch.

Example

  • To retrieve specific columns from the table
SELECT emp_id, emp_name
  FROM employees
 WHERE dept_number = 10;

Here, employee id and employee name belonging to department number 10 will be fetched.

  • Below query retrieve all columns from the table
SELECT * FROM employees;

Here, * retrieves all the columns of table employees.

As we have not mentioned any condition, all the table data will be retrieved.

  • To retrieve standard function from the table
SELECT SYSDATE FROM DUAL;

This query retrieves the current date.

  • Below query retrieves calculation output
SELECT 4+5 “Addition of 4 and 5” FROM DUAL;

The output of this query is 9.

  • Calculations of columns retrieved as below
SELECT salary + hike_percent “Salary increment” FROM employees;

Above query returns increment in salary by adding salary to hike_percent,

I hope you like the page and find it useful. We highly appreciate comments and feedback.

You can also Subscribe here to stay updated on latest posts of OracleMine.com.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.