Test Index

Structured Query Language (SQL) Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 36 of 58
Marks: +1, -0
Consider the table Projects given below :
Table : Projects
P_idPnameLanguageStartdateEnddate
P001School Management SystemPython2023-01-122023-04-03
P002Hotel Management SystemC++2022-12-012023-02-02
P003Blood BankPython2023-02-112023-03-02
P004Payroll Management SystemPython2023-03-122023-06-02
Based on the given table, write SQL queries for the following :
(i) Add the constraint, primary key to column P_id in the existing table Projects.
(ii) To change the language to Python of the project whose id is P002.
(iii) To delete the table Projects from MySQL database along with its data.
[CBSE 2024 Set 4]
Solution:  
(i)
ALTER TABLE Projects ADD PRIMARY KEY (P_id);
(ii)
UPDATE Projects
SET Language = 'Python'
WHERE P_id = 'P002';
(iii)
DROP TABLE Projects;
Key point: DROP TABLE removes the table together with its data; DELETE FROM Projects; would remove only the rows and keep the empty table.
© examsnet.com
Advertisements
Go to Question: