0% found this document useful (0 votes)
22 views2 pages

Lab 3

The document discusses adding and dropping primary keys and foreign keys on database tables. It also provides examples of SELECT queries using logical operators like WHERE, BETWEEN, IN, LIKE and joining multiple tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Lab 3

The document discusses adding and dropping primary keys and foreign keys on database tables. It also provides examples of SELECT queries using logical operators like WHERE, BETWEEN, IN, LIKE and joining multiple tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

que= add primary kry on supplier_numjber in supplier_master

ex = alter table tablename supplier_master add primary key(supplier_no)

que = add fk on sell_order_number in table sales-order-detail referencing table


sales-order
#modifi col quantity_order to include not null

ex = alter table s-o-n add constraint order_key foreign key(s-o-n) refernces


sales-order modify(quantity not null)

ques = draw primary key on supplier-master


ex = alter table supplier-master drop primary key;(only constraint in
deleted)

que = drop fk on product_number on sales-order-detail.


ex = alter table sales-order-deatail drop constraint fk-sales

-----------------------------------------------------------------------------------
--------------

#select from where

syntax = select col1, col2, .... from tablename where condition

ques = find the branch names from loan (relation or table.)


ans = select branch from loan.

ques = find the loan_nubers for loans made at the perryridge branch with loan
amount > $1200
ans = select loan_number from loan where branch =" per" and loan_amount > 1200

-----------------------------------------------------------------------------------
---------------

*logical test againt a list a list { in, not in, between, not between}

ex = page in (1,2,3)
page not in (1,2,3)
page between 6 and 10
page not between 10 and 20

*like operator:{%,_}
*logical operator{and, or, not}

ques = client-master(no,name,address, city,pincode)


1 show all the client lives in bombay or delhi
ans = select * from client-master where city = "bombay" or city = "delhi"
2 show the name of client where first two character of names are Jo
ans = select name from client_master where name like 'Jo%'

product-master(product,des,profit,sell-price)
1 show the product detail with profit percentage lies in the range 10 to 20
ans = select *from pm where profit_p between 10 to 20
2 show the pd for sale price 1200,1300,1500
ans = select * from pm where sal p in (1200,1300,1500)

----------------------------------------------

You might also like