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

Chapter 13

The document outlines various SQL commands for managing database tables, including selecting, updating, inserting, and deleting records. It also includes commands for altering table structures and creating new tables for employees, departments, and customers. Additionally, it demonstrates handling of constraints and data types within the database schema.

Uploaded by

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

Chapter 13

The document outlines various SQL commands for managing database tables, including selecting, updating, inserting, and deleting records. It also includes commands for altering table structures and creating new tables for employees, departments, and customers. Additionally, it demonstrates handling of constraints and data types within the database schema.

Uploaded by

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

CHAPTER – 13

1. select * from accounts where amt_outstanding > 10000 ;


2. update employee
set salary = salary + salary * 0.10
3. update empl
set comm = comm + 500
where hiredate between “1982-01-01” and “1982-12-31” ;
4. alter table empl
add ( city char( 50 ) ) ;
update empl
set city = “boston”
where empno = 7500;
5. delete from orders
where orders.ordno = payment.ordno and
orders.prodno=product.prodno
and payment.pment = orders.qty * product.price ;
6. show tables ;
7.
(i) update product
set price = price + price * 0.10

(ii)
select * from orders, product, payment where orders.ordno =
payment.ordno and prodno# = prodno and ( qty * price ) < pment ;

(iii) update product


set price=price - price*0.1
where product.prodno=orders.prodno and datediff(month,
orders.ord_date, getdate())>=10;
8. alter table empl add column grade varchar(1) ;
9. update empl
set grade = 1
where sal between 700 and 1500 ;

update empl
set grade = 2
where sal between 1500 and 2200 ;

update empl
set grade = 3
where sal between 2200 and 3000 ;

update empl
set grade = 4
where sal = 3000 ;
10. alter table empl add column grade int(1) not null ;
11. insert into empl(empno , ename , job , mgr , hiredate ,sal
,comm , deptno ) values( 8935, “path wala ”,
“salesman”,8862 , “1993-06-25” ,1000 , 110.00, 10 )

note:- it will return error because we did not enter grade.


grade should have a value
12. alter table empl modify column grade int(2) not null ;
13. drop table empl ;
14. create table department (id int(8) , name varchar (25) ) ;
15. insert into department
select id, name from dept ;
16. create table employee (id int(8) ,first_name varchar(25)
,last_name varchar(25),dept_id int(8)) ;
17. drop table employee ;
drop table department ;
18. create table customer (cust_id int (7) ,cust_name
varchar( 30 ) ,cust_address1 varchar (20) ,cust_address2
varchar (30) ,pincode int(6) ,cust_phone varchar(10)) ;
19. alter table customer add ( email varchar(30) ) ;
20. alter table customer add ( customerincomegroup
varchar(10) );
21. insert into customer values ( 1234, “path wala ”, “india”,
“up” , 211001 , 1234567890) ;

insert into customer values ( 1597, “portal express”, “india”,


“hp” , 245901 , 2468135790) ;
22. alter table customer
drop column customerlncomegroup ;
23. create table department (deptid int( 2 ) primary key
,deptname varchar (20) not null) ;
24. create table employee (empid int(6) primary
key,empname varchar(20) not null, empaddress varchar
(20),empphone varchar(10),
empsal int(9),deptid varchar(2),foreign key (deptid
) references department (dept_id)) ;
25. desc employee ;
desc department ;
desc customer ;

You might also like