SQL Primary Key
6.What happens if you try to insert duplicate values in PRIMARY KEY?
-
A. Warning
-
B. Replaces old row
-
C. Error
-
D. Ignores row
Error
Error
7.Which syntax defines a primary key on a single column?
-
A. CONSTRAINT pk PRIMARY(column);
-
B. PRIMARY KEY (column_name);
-
C. KEY (column)
-
D. PRIMARY (column)
PRIMARY KEY (column_name);
PRIMARY KEY (column_name);
8.Composite PRIMARY KEY refers to:
-
A. Two or more tables
-
B. More than one column used as a key
-
C. Duplicate keys
-
D. Primary and foreign key together
More than one column used as a key
More than one column used as a key
9.Which of the following automatically gets indexed in most RDBMS?
-
A. CHECK
-
B. DEFAULT
-
C. PRIMARY KEY
-
D. FOREIGN KEY
PRIMARY KEY
PRIMARY KEY
10.What will be the result of the given code?
CREATE TABLE product (
id INT PRIMARY KEY,
name VARCHAR(50)
);
ALTER TABLE product DROP PRIMARY KEY;
INSERT INTO product VALUES (1, 'Pen');
INSERT INTO product VALUES (1, 'Pencil');
-
A. Error: PRIMARY KEY already exists
-
B. Both rows inserted
-
C. Error due to duplicate
-
D. Table gets deleted
Both rows inserted
Both rows inserted