COMPUTER SCIENCE AND ENGINEERING
SQL
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
Which of the following command is the correct syntax for adding primary key constraint in existing table?
|
ALTER TABLE <tableName> ADD CONSTRAINT <constraintName> PRIMARY KEY(columnName);
|
|
ALTER TABLE <tableName> ADD CONSTRAINT PRIMARY KEY(columnName);
|
|
ALTER TABLE <tableName> ADD CONSTRAINT <columnName> PRIMARY KEY;
|
|
None of these
|
Explanation:
Detailed explanation-1: -The basic syntax of ADD CONSTRAINT is: ALTER TABLE table name ADD CONSTRAINT PRIMARY KEY (col1, col2); The above command would add a primary key constraint to the table table name .
Detailed explanation-2: -Add Primary key to the Existing Table. If you want to add a primary key in the existing table, you have to use the following ALTER syntax in SQL: ALTER TABLE Table Name ADD CONSTRAINT Constraint Name PRIMARY KEY (Column Name);
There is 1 question to complete.