0% found this document useful (0 votes)
9 views

Oracle_2

Uploaded by

mohammed.shohel9
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Oracle_2

Uploaded by

mohammed.shohel9
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Dual table:

Dual is a dummy table, it has only one column ( dummy ) with data type VARCHAR2 (1), and contains
one row with a value X.
It is a special table used for evaluating expressions or calling functions.

OPERATORS IN SQL
1) ARITHMETIC OPERATORS: ( +,-,*,/ )

We can use arithmetic operators to perform calculations on numerical values.


Ex1: select sal/2 from emp;
Ex2: select 300+400 from dual;

2 LOGICAL OPERATORS: (AND, OR, NOT)

Logical operators are used to filter the data based on conditions.

and: Select * from emp where deptno = 10 and sal> 1000;


or: Select * from emp where deptno = 10 or sal> 1000;
not: Select * from emp where deptno != 10;

3) RELATIONAL OPERATORS:

= à equal to
< àless than
> àgreater than
<= à less than equal to
>= à greater than equal to
!= à not equal to
<>à not equal to

Ex: select * from emp where salary <> 2000;

4) SPECIAL OPERATORS: (IS, IN, LIKE , NOT LIKE, ANY/SOME, ALL, BETWEEN, NOT BETWEEN )

IS: is operator is similar to ‘=’ operator.’


It is used to handle null values

Ex1: select * from emp where comm is null;


Ex2: select * from emp where comm is not null;

Note: Null values must be compared with ‘is’ operator.

IN & NOT IN :It is used compare in n number of values.


It is used to compare character, number and dates also
Ex: select * from emp where sal in ( 1000, 2000, 10,000 );
select * from emp where manager in (‘ram’, ‘martin’);
select * from emp where sal not in (4000,5000);

BETWEEN & NOT BETWEEN:

It is used provide range of values.

Ex : select * from emp where sal between 1000 and 3000;


select * from emp where sal not between 4000 and 6000;

LIKE & NOT LIKE:


It is used to search for pattern searching or character comparision

% à for the wild search.

_ àfor the single character or number

Ex: select * from emp where ename like ‘ra%’;


Select * from emp where ename like ‘p____‘;
Select * from emp where ename like ‘%p%’;

ANY/SOME:
It compares a value with every value in a list, it must be processed by = ,!=,>,<,>=,<=.
Ex: select * from emp where sal >= all (1400,3000);

5) SET OPERATORS:

Set operators are used to combine select statements.


The pre requisite condition to set operator is datatype of the corresponding columns should be same.
Set operators can be called as virtual joins.

The set operators as follows


1) Union >> it club the result of queries and eliminate the duplicate values.
2) Union all >> it club the result of queries and but duplicate values will not be eliminated.
3) Intersect >> it gives the common values between multiple query results.
4) Minus >> It gives the result of values which are present in first query and which are not present in
second query.

Ex: select empno from emp union select mgr from emp;
select empno from emp union all select mgr from emp;
select empno from emp intersect select mgr from emp;
select empno from emp minus select mgr from emp;

You might also like