Sunteți pe pagina 1din 3

1) CREATE a database with the name practice1.

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------
2) use the database practice1.
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
3) Create a table customerdetails with following fields in practice1.

customerid VARCHAR(6) PRIMARY KEY,


firstname VARCHAR(10),
middlename VARCHAR(10),
lastname VARCHAR(10),
address1 VARCHAR(50),
address2 VARCHAR(50),
mobilenumber VARCHAR(10)

-----------------------------------------------------------------------------------
--------------------------------------------------
4)

Enter the details as follows

customerid firstname middlename lastname address1


address2 mobilenumber
C00001 Ratna null Dutta a/10-Netaji-Nagar,Kolkata
a/65,Nehru Colony,Delhi 9345671234
C00002 Ashim Kumar Sagar a-122,Gandhi-Marg,Banglore null
6734675675
C00003 Rohini null Mathur 12/1, Bentick Street,Kolkata
a/45, Kulra, Mumbai 9844575554
-----------------------------------------------------------------------------------
-------------------------------------------

5) Display all the columns for all the records. Avoid using *.
6) Display firstname,lastname for all the records.
7) Display the firstname and customerid who don't have middlename.
8) Display all the details for customer whose address2 is null.
9) Display the customerid whose lastname is Dutta.
10) Display the mobilenumber for customerid C00001 and C00002.
11) Display the details of customer whose firstname is Rohina and lastname is
Mathur.
12) Update the mobilenumber for C00001 as 8756312345.
13) Update the middlename and lastname of the customer whose firstname is Ratna.
Make the lastname as Datta and middlename as Shree.
14) Delete the record of customer where the customerid is C00003.

15) Create one more table called itemdetails in the same practice database with
following fields.

itemid VARCHAR(6) PRIMARY KEY,


description VARCHAR(15),
price FLOAT(8,2)
item_cateory VARCHAR(20)

16) Enter the details as follows


itemid description price item_category
I00001 Shirt 1200 garments
I00002 Troussers 1900 garments
I00003 Wallet 1000 accessories
I00004 Belt 1300 accessories

17) Display the itemcode for garments.


18) Display the itemid and description where the price is 1200.
19) Display the itemid and description where the price is more than 1000.
20) Display the itemid and description where the price is more than and equal to
1200.
21) Display the itemid and description where the price is between 1300 and 1900.
(Inclusive 1300 and 1900)
23) Display the itemid and price of Wallet.
24) Display the itemid and description of the item which is having a price of 1200
in garments.
25) Display the itemid and description which is more than 1500 in garments
category.
26) Display the itemid and description where the price is less than 1500.
27) Display the itemid and description where the price is between 1300 and 1900
(Exclusive 1300 and 1900).
28) Display the description of itemid I00001, I00003 and I00004.
29) Display the itemid and price of item which is not a shirt.
30) Update the price of itemid I00004 by 1000 . Currently price is 1300 , after
update it should be 2300.
31) Add one more record I00005 whose item description is T-shirt and price is null
and item_category is garements.
32) Delete the itemid I00001.
-----------------------------------------------------------------------------------
---------------------------------------------------------------------------------

33) Create one more table called item_transaction with the following details

transaction_id VARCHAR(6) PRIMARY KEY,


itemid VARCHAR(6),
customerid VARCHAR(6),
date_of_purchase DATE

34) INSERT the following details

transaction_id itemid customerid date_of_purchase


T00001 I00001 C00001 2013-10-10
T00002 I00010 C00001 2014-10-12
T00003 I00002 C00011 2016-12-11

35) Display the itemid which was purchase on 2013-10-10.


36) Display the date_of_purchase for the transaction T00003.
37) Try to insert the following details in item_trasaction

transaction_id itemid customerid date_of_purchase


null I00001 C00001 2016-12-12

Are we able to insert the record? What error message is shown?


38) Insert the following record

transaction_id itemid customerid date_of_purchase


T00002 I00001 C00001 2016-12-12

Are we able to insert thr record? What error message is shown?

39) What is a primary key? What is the purpose of declaring a primary key? What do
you understand by composite primary key?
Can we have multiple primary keys in a table? What are the restrictions related
to primary key?

40) What do you understand by null value?

S-ar putea să vă placă și