23. View the Exhibit and examine the structure of the CUST table.
Evaluate the following SQL statements executed in the given order:
ALTER TABLE cust
ADD CONSTRAINT cust_id_pk PRIMARY KEY(cust_id) DEFERRABLE INITIALLY DEFERRED
INSERT INTO cust VALUES (1,'RAJ'); --row1
INSERT INTO cust VALUES (1,'SAM'); --row2
COMMIT;
此时PRIMARY KEY状态DEFERRABLE INITIALLY DEFERRED,在commit是检查约束,row1,row2一起提交,同时失败
SET CONSTRAINT cust_id_pk IMMEDIATE;
此时PRIMARY KEY状态DEFERRABLE INITIALLY IMMEDIATE,发出命令后立即检查约束
INSERT INTO cust VALUES (1,'LATA'); --row3
发出命令检查约束,执行成功
INSERT INTO cust VALUES (2,'KING'); --row4
发出命令检查约束,执行成功
COMMIT;
提交成功
Which rows would be made permanent in the CUST table?
A. row 4 only
B. rows 2 and 4
C. rows 3 and 4(right)
D. rows 1 and 4
Evaluate the following SQL statements executed in the given order:
ALTER TABLE cust
ADD CONSTRAINT cust_id_pk PRIMARY KEY(cust_id) DEFERRABLE INITIALLY DEFERRED
INSERT INTO cust VALUES (1,'RAJ'); --row1
INSERT INTO cust VALUES (1,'SAM'); --row2
COMMIT;
此时PRIMARY KEY状态DEFERRABLE INITIALLY DEFERRED,在commit是检查约束,row1,row2一起提交,同时失败
SET CONSTRAINT cust_id_pk IMMEDIATE;
此时PRIMARY KEY状态DEFERRABLE INITIALLY IMMEDIATE,发出命令后立即检查约束
INSERT INTO cust VALUES (1,'LATA'); --row3
发出命令检查约束,执行成功
INSERT INTO cust VALUES (2,'KING'); --row4
发出命令检查约束,执行成功
COMMIT;
提交成功
Which rows would be made permanent in the CUST table?
A. row 4 only
B. rows 2 and 4
C. rows 3 and 4(right)
D. rows 1 and 4