Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
82 views

Database Practical Course

This document contains examples of SQL statements for inserting, updating, and deleting data from database tables. It includes examples of: 1) Inserting multiple records into tables using different column lists and value orders. 2) Creating new tables and inserting select statements to populate them from joins on other tables. 3) Updating existing records by multiplying salaries for certain departments or setting salaries to half for research and headquarters. 4) Deleting records from tables by last name, social security number, or department number.

Uploaded by

romissaa
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

Database Practical Course

This document contains examples of SQL statements for inserting, updating, and deleting data from database tables. It includes examples of: 1) Inserting multiple records into tables using different column lists and value orders. 2) Creating new tables and inserting select statements to populate them from joins on other tables. 3) Updating existing records by multiplying salaries for certain departments or setting salaries to half for research and headquarters. 4) Deleting records from tables by last name, social security number, or department number.

Uploaded by

romissaa
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

DATABASE

PRACTICAL
COURSE

Eman Marzban 1
INSERT

1) Insert into employee values ('richard', 'k', 'marini',


'4234355665', '1960/2/30', '98 oak forest', 'm', 37000,
'3455345',4)
2) Insert into employee values ('richard', 'k', 'marini',
'4234355665', '1960/2/20', '98 oak forest', 'm',
37000,'987654321',4)
3) Insert into employee (fname, lname, dno, ssn) values
('richard ', ' marini', 4, '323576476547‘)
4) Insert into employee (sex,salary, bdate, fname, lname,
minit, dno, ssn) values ('m',2300,'12/12/70','richard ', '
marini','g', 4, '323576476547')

Eman Marzban 2
5) Create table Depts_Info (Dept_Name varchar (15),
No_Emps int, total_sal int )
6)Insert into Depts_Info Select (dname, count(*),
sum(salary)) from (department join employee on
dnumber=dno) group by dname
7) Select dname, count(*), sum(salary) from (department join
employee on dnumber=dno)
8) Select dname, count(*), sum(salary) from (department join
employee on dnumber=dno)group by dname
9) Create table Fem_Depts_Info (Dept_Name varchar (15),
fssn varchar (50), salary int, fname varchar(50), minit
varchar (1), lname varchar (15), dno int)

Eman Marzban 3
10) Select * from (dependent join
employee on essn=ssn ) where
employee.sex= 'f'
11) insert into Fem_Depts_Info Select
depname, ssn, salary, fname, minit,
lname, dno from (dependent join
employee on essn=ssn ) where
employee.sex='f'

Eman Marzban 4
UPDATE
1 ) update project set plocation='bellaire', dnum=5
where pnumber =10
n
2) Update employee set salary=1.1* salary where dno
in (select dnumber from department where
dname='research ' )
3) select dnumber from department where
dname='research ' or dname='Headquarters'
Update employee set salary=0.5* salary where dno in
(select dnumber from department where
dname='research ' or dname='Headquarters')

Eman Marzban 5
DELETE
1) Delete from employee where lname= 'brown'
2) delete from employee where ssn='123456789'
3) Delete from employee where dno in (select
dnumber from department where dname
=‘research’)
4) select *from employee except (select* from
employee where dno not in (select dnumber from
department where dname ='research'))
5) select* from employee where dno not in (select
dnumber from department where dname
='research')
Eman Marzban 6

You might also like