PrepAway - Latest Free Exam Questions & Answers

How many rows will be deleted by the following DELETE statement?

The following statements:
CREATE TABLE t1 (col1 INT NOT NULL, PRIMARY KEY (col1));
CREATE TABLE t2 (col1 INT NOT NULL, col2 CHAR(1) NOT NULL, PRIMARY KEY (col1, col2),
FOREIGN KEY (col1) REFERENCES t1 (col1)
ON DELETE CASCADE ON UPDATE RESTRICT);

CREATE TABLE t3 (col1 INT NOT NULL, col2 INT NOT NULL, PRIMARY KEY (col1, col2),
FOREIGN KEY (col1) REFERENCES t1 (col1)
ON DELETE NO ACTION ON UPDATE RESTRICT);
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 VALUES (1, ‘a’), (1, ‘b’), (2,’c’);
INSERT INTO t3 VALUES (1, 100), (2, 200), (2,300);
How many rows will be deleted by the following DELETE statement? DELETE FROM t1 WHERE
col1 = 1;

PrepAway - Latest Free Exam Questions & Answers

A.
4

B.
3

C.
1

D.
0

2 Comments on “How many rows will be deleted by the following DELETE statement?

  1. swamy says:

    RESTRICT means that any attempt to delete and/or update the parent will fail throwing an error. This is the default behaviour in the event that a referential action is not explicitly specified.

    NO ACTION is the same as RESTRICT.




    0



    0

Leave a Reply