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
1 Like
Related Questions
What is a server?
Write the output for the following print statements in Python.
Sub_Teacher = {"English":"Mr. Gill", "Maths": "Mr. R.N. Pandey", "IP":"Ms. Renu Ahuja", "Physics": "Ms. Meenu Lal", "Chemistry":"Ms. Mamta Goel"} print(Sub_Teacher['Chemistry']) #Line1 print(Sub_Teacher.keys()) #Line2 print(len(Sub_Teacher)) #Line3The data type list is an ordered sequence which is mutable and made up of one or more elements. Unlike a string which consists of only characters, a list can have elements of different data types such as integer, float, string, tuple or even another list. A list is very useful to group elements of mixed data types. Elements of a list are enclosed in square brackets and are separated by comma.
(i) How is a list different from a dictionary?
(ii) Find the values of y and z after execution:
x=[2, 3] y=[30, 40] z=[88, 99] y.extend(x) z.append(x) print (y) print (z)Write a program in Python to input elements in an empty list. Also delete an element from the list which a user will input.