Professional Documents
Culture Documents
Structured Query
Language
SQL is the language
used to communicate
with the Oracle Database.
Syntax of INSERTStatement
Insert into <tablename> values
(Col1,Col2,Col3..Col n);
Snam e
V a rc h a r2 (2 0 )
B ra n c h
V a rc h a r2 (2 0 )
S e m is t e r
(V a rc h a r2 (1 0 )
P honeno
N u m b e r(7 )
Relational Operators
Logical Operators
SQL Operators
Functions
Single Row
Group functions
Character
Sum()
Number
Date
Max()
Min()
Avg()
Conversion
Count()
Group Functions
These functions operate on a set of records or on the
entire table. They are therefore called as Group or
Aggregate Functions
Sum() SQL> Select sum(sal) from emp;
Avg() SQL> Select avg(sal) from emp;
Max() SQL> Select max(sal) from emp;
Min() SQL> Select min(sal) from emp;
count() SQL> Select count(*) from emp;
Group Functions
Sum() SQL> Select sum(sal) from emp where deptno =
10;
Avg() SQL> Select avg(sal) from emp where
desgn=Clerk and deptno = 10;
Max() SQL> Select max(sal) from emp where deptno in
(10,20,30);
Min() SQL> Select min(sal) from emp where doj like
%98;
count() SQL> Select count(*) from emp where sal
between 3000 and 5000;
GROUP BY CLAUSE
Joins
Examples of Joins
Example of Equi-Joins :
Display the empno,name, deptno and dname .
SQL> Select empno,name,emp.deptno,dname from
emp,dept where emp.deptno=dept.deptno
Grade
1
2
3
Losal
2000
3000
5000
Hisal
2999
4999
5999
Mgr
102
103
101
101
102
Example of Outer-Join :
Display all departments which are not present in the EMP table.
Integrity Constraints
Integrity Constraints are the rules with which the
contents of a database must comply at all times,
and they describe which updates to the database
are permitted
Types : Table Constraints, Column Constraints
Not Null
Primary Key
Unique
Check
Foreign Key
SUB-QUERIES
These are used to specify a subset of rows
whose defining characteristics
(WHERE Clause) are dependent on the values
returned from another Query
Syntax:
Select col1,col2,col3.. From table
Where column= ( Select column from table
where <condn>);
Thank You