KnowledgeBoat Logo

Computer Science

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

SQL Queries

3 Likes

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) ;

Answered By

2 Likes


Related Questions