0% found this document useful (0 votes)
8 views4 pages

SQL Class.

Uploaded by

shop4kumar
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)
8 views4 pages

SQL Class.

Uploaded by

shop4kumar
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/ 4

Tables

Rows &

Colums

EMP

Emp_ID

EMP_NAME

ADDress

CREATE TABLE employees (


EMP_ID number(10)
UNIQUE,
varchar2(50) NOT NULL,
EMP_NAME
ADD varchar2(50) );

Select * from EMP;

EMP_I EMP_NA ADDRES


D ME SS
1 RAJ Albany
2 Jack NY
3 ROB NJ
4 Joe NC
5 Bill SC
6 Sri AT

Select * from EMP where EMP_ID=4;

4 Joe NC
Select * from EMP where EMP_ID in (1,4);

EMP_NAM
EMP_ID E DEPT_ID
1 RAJ 10
4 Joe 10

Select a.EMP_ID, a.EMP_NAME, b.Sal from EMP a , SAL b where a.EMP_ID =b. EMP_ID and

a.EMP_ID=1;

Sal
EMP_ID EMP_NAME
100
1 RAJ

Select * from SAL where EMP_ID=4;

4 4/6/2024 Joe 10
4 5/6/2024 Joe 10

Select * from EMP join SAL;

EMP_NAM
EMP_ID E ADDRESSS Date Sal
4/6/202
1 RAJ Albany 4 100
4/6/202
2 Jack NY 4 90
4/6/202
3 ROB NJ 4 10
4/6/202
4 Joe NC 4 10
4/6/202
5 Bill SC 4 10
4/6/202
6 Sri AT 4 10

Left Right

Select * from EMP a left join SAL b where a. EMP_ID=b. EMP_ID ;

EMP_NAM
EMP_ID E ADDRESSS Date Sal
4/6/202
1 RAJ Albany 4 100
2 Jack NY 4/6/202 90
4
4/6/202
3 ROB NJ 4 10
4/6/202
4 Joe NC 4 10
4/6/202
5 Bill SC 4 10
4/6/202
6 Sri AT 4 10

Select * from EMP a right join SAL b where a. EMP_ID=b. EMP_ID ;

ADDRESS
EMP_NAM S
EMP_ID Date E Sal
4/6/202 Albany
1 4 RAJ 100
4/6/202 NY
2 4 Jack 90
4/6/202 NJ
3 4 ROB 10
4/6/202 NC
4 4 Joe 10
4/6/202 SC
5 4 Bill 10
4/6/202 AT
6 4 Sri 10
5/6/202
1 4 RAJ 100
5/6/202
2 4 Jack 90
5/6/202
3 4 ROB 10
5/6/202
4 4 Joe 10
5/6/202
5 4 Bill 10
5/6/202
6 4 Sri 10

Create view emp_dept as select a.emp_id,a.emp_name,b.dept_id from emp a,dept b where a


emp_id=b. emp_id;
Select * from emp_dept;

EMP_NAM DEPT_ID
EMP_ID E
10
1 RAJ
10
2 Jack
10
3 ROB
10
4 Joe
10
5 Bill

Select DRL:

Insert DML

Delete DML

Insert into EMP (EMP_ID,EMP_NAME,ADDRESSS) values (7, Jill,VX);

Rollback;

Insert into EMP (EMP_ID,EMP_NAME,ADDRESSS) values (7, Jill,VA);

Insert into EMP (EMP_ID,EMP_NAME,ADDRESSS) values (7, Jill,VX);

Commit;

Update EMP set ADDRESSS=’VA’ where EMP_ID=7;

Commit;

You might also like