2. Choose appropriate answer with respect to the following code snippet.
CREATE TABLE student ( name CHAR(30), student_id INT, gender CHAR(1), PRIMARY KEY (student_id));

(i) What will be the degree of student table?
a) 30
b) 1
c) 3
d) 4
Ans: 3 (degree means columns and total no of columns are 3)

(ii) What does ‘name’ represent in the above code snippet?
a) A table
b) A row
c) A column
d) A database
Ans: A column

(iii) What is true about the following SQL statement?
SelecT * fROM student;

a) Display content of table ‘student’
b) Display column names and content of table ‘student’
c) Results in error as improper case has been used
d) Display only the column names of table ‘student’
Ans: ii. Display column name and content of table ‘student’.
(Because SQL is not case-sensitive)

(iv) What will be output of following query?
INSERT INTO student
VALUES (“Suhana”, 109, ‘F’),
VALUES (“Rivaan”, 102, ‘M’),
VALUES (“Atharv”, 103, ‘M’),
VALUES (“Rishika”, 105, ‘F’),
VALUES (“Garvit”, 104, ‘M’),
VALUES (“Shaurya”, 109, ‘M’);

(a) Error
(b) No Error
(c) Depends on Compiler
(d) Successful compilation of the query

Ans:
(a) Error

(Because we cannot use ‘VALUE’ keyword multiple times with single INSERT clause and also we are trying to insert value 109 two times in student_id column which is not possible because it is PRIMARY KEY)

(v) In the following query how many rows will be deleted?
DELETE student WHERE student_id =109;1
(a) row
(b) All the rows where student ID is equal to 109
(c) No rows will be deleted
(d) 2 rows

Ans: i. 1 row
(Because student_id is a primary key and so it has all unique values.)

error: Content is protected !!