Tuesday, 7 August 2012

SQL Operators


SQL Operators
PL/SQL lets you use all the SQL comparison, set, and row operators in SQL statements. This section briefly describes some of these operators. For more information, see Oracle Database SQL Reference.
Comparison Operators
Typically, you use comparison operators in the WHERE clause of a data manipulation statement to form predicates, which compare one expression to another and yield TRUE, FALSE, or NULL. You can use the comparison operators in the following list to form predicates. You can combine predicates using the logical operators AND, OR, and NOT.
Operator
Description
ALL
Compares a value to each value in a list or returned by a subquery and yields TRUE if all of the individual comparisons yield TRUE.
ANY, SOME
Compares a value to each value in a list or returned by a subquery and yields TRUE if any of the individual comparisons yields TRUE.
BETWEEN
Tests whether a value lies in a specified range.
EXISTS
Returns TRUE if a subquery returns at least one row.
IN
Tests for set membership.
IS NULL
Tests for nulls.
LIKE
Tests whether a character string matches a specified pattern, which can include wildcards.

Set Operators
Set operators combine the results of two queries into one result. INTERSECT returns all distinct rows selected by both queries. MINUS returns all distinct rows selected by the first query but not by the second. UNION returns all distinct rows selected by either query. UNION ALL returns all rows selected by either query, including all duplicates.
Row Operators
Row operators return or reference particular rows. ALL retains duplicate rows in the result of a query or in an aggregate expression. DISTINCT eliminates duplicate rows from the result of a query or from an aggregate expression. PRIOR refers to the parent row of the current row returned by a tree-structured query.

2 comments: