Do you want to learn Oracle Database or Oracle statement?? In this tutorial, you will learn how to write Oracle SELECT statement or query.

Database tables are consists of columns and rows. We use the oracle select statement to retrieve data from one or more columns of a table or view, with the following basic syntax:

Note that the SELECT statement is very complex that consists of many clauses such as  ORDER BYGROUP BYHAVINGJOIN. To make it simple, in this tutorial, we are focusing on the SELECT and FROM clauses only.

Oracle SELECT examples

For example, we use the Employees table in the sample database that has the following columns: employee_id, first_name, last_name, email, phone and hire_date, manager_id, job_title. The  Employees table also has data in these columns.

 
Query data for a single column

To get a single column like first_name from the Employees table, you use the following statement:

Query data for multiple columns

To get data from multiple columns, you specify a list of comma-separated column names. The following example shows how to query data from the  first_name, last_name, and  email columns of the Employees table.

Query data for all columns of a table

The retrieves all columns of the Employees table you can write all column names. You can also use the shorthand asterisk (*) to instruct Oracle to return data from all columns of a table as follows:

Select query from Dual table

In Oracle, the SELECT statement must have a FROM clause. However, some queries don’t require any table like UPPER() function. Fortunately, Oracle provides you with the  DUAL table which is a special table. By using the  DUAL table, you can execute queries that contain functions that do not involve any table like the  UPPER() function as follows:

 

Leave a Comment

1 Comment