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

Kishinchand Chellaram College, Mumbai - 20: FY / SY / TY B.Sc. (I.T.) Semester

The document provides SQL commands to create and populate tables to store book data in a database. It creates a Book table with columns for book details, inserts sample book records, updates prices and publishers, deletes some records, and adds a column to the Book table before dropping the Books table.

Uploaded by

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

Kishinchand Chellaram College, Mumbai - 20: FY / SY / TY B.Sc. (I.T.) Semester

The document provides SQL commands to create and populate tables to store book data in a database. It creates a Book table with columns for book details, inserts sample book records, updates prices and publishers, deletes some records, and adds a column to the Book table before dropping the Books table.

Uploaded by

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

Kishinchand Chellaram College, Mumbai 20

FY / SY / TY B.Sc.(I.T.) Semester __________

1.Create table book with column book_id, title, author, publisher, category, yop, price. Make the book_id as the PK column. CREATE TABLE Book ( book_id VARCHAR(3) PRIMARY KEY, title VARCHAR(30), author VARCHAR(30), publisher VARCHAR(30), category VARCHAR(30), yop NUMERIC(4), price MONEY ) 2.Insert atleast 2 records for all columns in the book table INSERT INTO Book VALUES('b1','Harry Potter - Part1','J.K. Rowling','Tata Hill','Fiction',2000,495) INSERT INTO Book VALUES('b2','Star Wars','James','Microsoft Press','SciFi',2003,300)

3.Insert Value for book_id, yop, and price in the book table INSERT INTO Book (book_id,yop,price) VALUES ('b3',1998,215)

4.Create books table with column title, author, publisher and price. CREATE TABLE Books( title VARCHAR(30), author VARCHAR(30), publisher VARCHAR(30), price MONEY ) 5.Insert the details of books which are priced >300 in the books table. INSERT INTO Books SELECT title,author,publisher,price FROM Book WHERE price>300

Kishinchand Chellaram College, Mumbai 20


FY / SY / TY B.Sc.(I.T.) Semester __________

6.Change the price of book b1 to 300. UPDATE Book SET price=300 WHERE book_id='b1'

7.Increase the price of all books by 20% in the book table whose yop is before 2003. UPDATE Book SET price=(0.2*price)+price WHERE yop<2003

8.Change the publisher name for all microsoft press to mp and increase the price by 10%. UPDATE Book SET publisher='MP',price=0.1*price+price WHERE publisher='Microsoft Press'

9.Change the publisher name for all IT books to international press and reduce the price by 30. UPDATE Book SET publisher='International Press',price=price-30 WHERE category='IT'

10.Delete all books published by Tata Hill. DELETE FROM Book WHERE publisher ='Tata Hill'

11.Delete all records from books table. DELETE FROM Books

12.Delete all books whose price is greater than average price of the account category. DELETE FROM Book WHERE price>(SELECT avg(price) FROM Book WHERE category='Accounts')

13.Add column discount to the book table. ALTER TABLE Book ADD Discount MONEY

14.Delete the books table DROP TABLE Books

You might also like