Professional Documents
Culture Documents
Oracle Clauses
Oracle Clauses
Clauses----------------------------------------
-----------------------------------where
clause----------------------------------------------
The SQL WHERE clause is used to specify a condition while fetching the data from a
single table or by joining with multiple tables. If the given condition is
satisfied, then only it returns a specific value from the table. You should use the
WHERE clause to filter the records and fetching only the necessary records.
The WHERE clause is not only used in the SELECT statement, but it is also used in
the UPDATE, DELETE statement, etc., which we would examine in the subsequent
chapters.
Syntax
The basic syntax of the SELECT statement with the WHERE clause is as shown below.
Example- Extract ID, Name and Salary fields from the CUSTOMERS table, where the
salary is greater than 2000 −
Example- Extract ID, Name and Salary fields from the CUSTOMERS table for a customer
with the name Hardik.
-----------------------------------
DISTINCT----------------------------------------------------------------
Oracle DISTINCT clause is used to remove the duplicate records from the result set.
It is only used with SELECT statement.
Syntax:
tables: It specifies the table from where you want to retrieve records
---------------------------------------------------FROM
Clause------------------------------------------------------------
FROM clause is a mandatory clause in SELECT expression. It specifies the tables
from which data is to be retrieved.
Syntax:
FROM table_name...
----------------------------------------------------ORDER BY
Clause----------------------------------------------------
In Oracle, ORDER BY Clause is used to sort or re-arrange the records in the result
set. The ORDER BY clause is only used with SELECT statement.
Syntax:
SELECT expressions
FROM tables
WHERE conditions
ORDER BY expression [ ASC | DESC ];
Syntax
Where condition 1
AND condition 2
.
.
.
.
AND condition n
--------------------------------------------------
BETWEEN--------------------------------------------------------------------
In Oracle, BETWEEN is used to get the values from given range in select, insert,
delete or update statement
Syntax
Expression BETWEEN value1 AND value2;
---------------------------------------------------Comparison
operators----------------------------------------------------
--------------------------------------------------- IN
Operator-------------------------------------------------------------
ORACLE IN
In Oracle, In clause is used with SELECT, INSERT, UPDATE, or DELETE statement to
decrease the use of multiple OR conditions.
Syntax
expressions IN (value1, value2,.... value n)
------------------------------------IS NOT
NULL--------------------------------------------------------------------------
In oracle, IS NOT NULL is used to check not null values. It is used with select,
insert, update, and delete statements.
Syntax
expression IS NOT NULL
Note:
In IS NOT NULL, condition returns true values.
In NULL, condition returns false.
------------------------------------
NULL-------------------------------------------------------------------------------
--
In oracle, IS NULL is used to check not null values. It is used with select,
insert, update, and delete statements.
------------------------------------NOT
condition-----------------------------------------------------------------------
In Oracle, NOT condition is used with SELECT, INSERT, UPDATE or DELETE statement.
It is also called NOT operator. It is used to negate the given condition.
Syntax
NOT condition