CBSE Class 12 Computer Science Question 27 of 42

Solved 2024 Sample Question Paper CBSE Class 12 Computer Science (083) — Question 9

Back to all questions
9
Question

Question 24(a)

Ms. Shalini has just created a table named “Employee” containing columns Ename, Department and Salary. After creating the table, she realized that she has forgotten to add a primary key column in the table. Help her in writing an SQL command to add a primary key column EmpId of integer type to the table Employee. Thereafter, write the command to insert the following record in the table:

EmpId - 999
Ename - Shweta
Department: Production
Salary: 26900

Answer

SQL command to add primary key in the table:

ALTER TABLE Employee ADD EmpId INTEGER
PRIMARY KEY ;

SQL command for inserting data will be:

INSERT INTO Employee (EmpId, Ename, Department, Salary)
VALUES (999, "Shweta", "Production", 26900) ;