Вы находитесь на странице: 1из 2

SQL Practical Questions

1) ITEM

I_ID Item_Name Manufacturer Price


PC01 Personal Computer HP 35000
LC05 Laptop HP 55000
PC03 Personal Computer Toshiba 32000
PC06 Personal Computer Dell 37000
LC03 Laptop Lenovo 57000

CUSTOMER

C_ID Customer_Name City I_ID


01 N Roy Delhi LC03
06 H Singh Mumbai PC03
12 R Pandey Delhi PC06
15 C Sharma Delhi LC03
16 K Agarwal Bangalore PC01
Write the SQL queries for the followings:
i) Create the table given above in SQL. Set I_ID and C_ID as primary key for the tables ITEM and
CUSTOMER respectively. Set I_ID as a foreign key in the CUSTOMER table.
ii) Insert the data given above in the tables.
iii) To display different city to which the customer belongs.
iv) To display the highest price of each item.
v) To display the names of the customers who have bought laptops of Lenovo company.
vi) Decrease the price of items of HP Company by 5%.

2)Consider the following tables BOOKS and ISSUED. Write SQL command for the following:-

Books
Book_Id Book_name Author_name Publishers Price Type Qty
C0001 Fast Cook Lata Kapoor EPB 355 Cookery 5
F0001 The Tears William First Publ. 650 Fiction 20
Hopkins
T0001 My First C++ Brain and EPB 350 Text 10
Brooke
T0002 C++ A.W. TDH 350 Text 15
Brainworks Rossaine
F0002 Thunderbolts Anna Roberts First Publ. 750 Fiction 50

Issued
Book_Id Quantity_Issued
T0001 4
C0001 5
F0001 2

Write the SQL queries for the followings:


I. Create the table given above in SQL. Set Book_ID as primary key in table Books and foreign
key in table Issued.

II. Insert the data given above in the tables.


III. To show Book name, Author name and Price of books of First Publ. Publisher.
IV. To display the names and price from Books in ascending order of their price.
V. To increase the price of all books of EPB Publisher by 50.
VI. To insert a new row in the table issued having the following data “F0003”, 1.

Вам также может понравиться