0% found this document useful (0 votes)
6 views5 pages

Operators in Oracle

The document outlines various types of operators in Oracle, including arithmetic, relational, logical, special, and set operators. It explains how to use the SELECT command to display data from tables, including the use of the WHERE clause to filter specific rows based on conditions. Additionally, it discusses compound conditions and provides examples of SQL queries for different scenarios, such as filtering employees based on salary and hire date.

Uploaded by

duneshvasa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Operators in Oracle

The document outlines various types of operators in Oracle, including arithmetic, relational, logical, special, and set operators. It explains how to use the SELECT command to display data from tables, including the use of the WHERE clause to filter specific rows based on conditions. Additionally, it discusses compound conditions and provides examples of SQL queries for different scenarios, such as filtering employees based on salary and hire date.

Uploaded by

duneshvasa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

OPERATORS IN ORACLE:

1. Arithmetic Operators  [+, -, *, /]


2. Relational Operators [=>, >, <, <=, =, <>, !=]
3. Logical Operators [AND, OR, NOT]
4. Special Operators [BETWEEN, IN, LIKE, IS, ANY, ALL, EXISTS, PIVOT]
5. Set Operators [UNION, UNION ALL, INTERSECT, MINUS]

DISPLAYING DATA:
 “SELECT” command used to display data from table.
 We can display all rows columns of specific columns.

SELECT COLUMNS/*
FROM TABLENAME
[WHERE CONDITION];

SQL = ENGLISH
QUERIES = SENTENCES
CLAUSES = WORDS

EX:

DISPLAY EMPLOYEE NAMES AND SALARIES?

SQL> SELECT ENAME, SAL FROM EMP;

DISPLAY NAMES ,SALARIES AND HIREDATES?

SQL> SELECT ENAME, SAL, HIREDATE FROM EMP;

DISPLAY ALL THE DATA FROM EMP?

SQL> SELECT * FROM EMP;

WHERE clause:

 Used to select specific row/ rows from table.

WHERE condition;

 If condition = true row is selected, if false row us not selected;

Condition:

COLNAME OP VALUE;
EX:

DISPLAY EMPLOYESS DETAILS WHOSE ID =101?

SELECT *

FROM EMP

WHERE EMPID=101;

DISPLAY EMPLOYEE ENAME,SAL WHOSE ID=101?

SELECT ENAME,SAL

FROM EMP

WHERE EMPID=101;

DISPLAY EMP DETAILS DETAILS WHOSE NAME IS DK?

SELECT *

FROM EMP

WHERE ENAME=’DK’;

NOTE

In ORACLE, string comparision is case sensitive i.e. uppercase and lowercase strings are not
same.

EMP EARNING GREATER THAN 5000?

SELECT *

FROM EMP

WHERE SAL<=5000;

EMP EARNING LESS THAN 5000?

SELECT *

FROM EMP

WHERE SAL>=5000;
EMP JOINED AFTER 2022?

SELECT *

FROM EMP

WHERE HIREDATE>2022; ERROR

SELECT *

FROM EMP

WHERE HIREDATE>’31-DEC-2022’;

EMPLOYEE NOT BELONGS TO 20TH DEPT?

SELECT *

FROM EMP

WHERE DNO <> 20;

OR

SELECT *

FROM EMP

WHERE DNO != 20;

COMPOUND CONDITION:
 Multiple conditions combined wIth AND/ OR operators is called COMPOUND CONDITION.

WHERE COND1 AND/ OR COND2 RESULT

EX: WHERE CATEGORY=’MOBILES’ AND PRICE <20000;  Only select mobile under 20000

EMP WORKING AS CLERK, DEVELOPER>


SELECT *
FROM EMP
WHERE JOB=’CLERK’ OR JOB=’DEVELOPER’;

SELECT *
FROM EMP
WHERE JOB=’CLERK’ AND JOB=’DEVELOPER’;

EMP WHOSE ID=100,101?


SELECT *
FROM EMP
WHERE EMPID=101 OR EMPID=100;

EMP WORING AS CLERK AND EARNING MORE THAN 2000?


SELECT *
FROM EMP
WHERE JOB=’CLERK’ AND SAL>2000;

EMPLOYEE EARNING MORE THAN 5000 AND LESS THAN 10000?


SELECT *
FROM EMP
WHERE SAL>5000 AND SAL<10000;

EMP JOINED IN 2022?


SELECT *
FROM EMP
WHERE HIREDATE >= ’01-JAN-2022’ AND HIREDATE<=’31-DEC-2022’;

SELECT *
FROM EMP
WHERE HIREDATE >= ’01-JAN-2022’ AND HIREDATE<=SYSDATE;

EMP WORING AS CLERK, DEVELOPER AND EARNING MORE THAN 5000?


SELECT *
FROM EMP
WHERE JOB=’CLERK’ OR JOB=’DEVELOPER’ AND SAL>5000;
---------------- ----------------------------------------------
NOTE: Above query returns clerk records earning less than 5000 because operators NAD has
got more priority than operator OR, to overcome use ( ).

SELECT *
FROM EMP
WHERE (JOB=’CLERK’ OR JOB=’DEVELOPER’) AND SAL>5000;

STUDENT
SNO SNAME S1 S2 S3 S4
1 A 80 90 70 60
2 B 30 60 50 50

List of students who are passed?


SELECT *
FROM STUDENT
WHERE S1>=35 AND S2>=35 AND S3>=35;

List of students who are fail?


SELECT *
FROM STUDENT
WHERE S1<35 OR S2<35 OR S3<35;
IN OPERATOR:

 Use IN operator for list compression i.e “=” comparssion with multipy values.

You might also like