KnowledgeBoat Logo
|

Informatics Practices

Rohit, a Librarian has created a Table Book with the following fields:

Bookid, Bookname, Author and Price. He has entered 20 records in the table.

Which command should he use to do the following:

(i) To change the price of Computer Science book from 450 to 500.

(ii) To insert Primary Key in the table.

(iii) What is the difference between delete and drop command.

SQL Queries

1 Like

Answer

(i)

UPDATE Book
SET Price = 500
WHERE Bookname = 'Computer Science' AND Price = 450;

(ii)

ALTER TABLE Book
ADD CONSTRAINT pk_Bookid PRIMARY KEY (Bookid);

(iii) DELETE command is used to remove all the contents from the table, leaving it empty. On the other hand, the DROP command is used to delete the table from the database along with all its data and structure.

Answered By

2 Likes


Related Questions