Skip to content
Exercises · Q2

Q.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)
);

a) What will be the degree of student table?
i) 30
ii) 1
iii) 3
iv) 4
b) What does 'name' represent in the above code snippet?
i) a table
ii) a row
iii) a column
iv) a database
c) What is true about the following SQL statement?
SelecT * fROM student;
i) Displays contents of table 'student'
ii) Displays column names and contents of table 'student'
iii) Results in error as improper case has been used
iv) Displays only the column names of table 'student'
d) What will be the 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');
i) Error
ii) No Error
iii) Depends on compiler
iv) Successful completion of the query
e) In the following query how many rows will be deleted?
DELETE student
WHERE student_id=109;
i) 1 row
ii) All the rows where student ID is equal to 109
iii) No row will be deleted
iv) 2 rows
Tripura TbseTextbookMCQ· 1mImportance★★★★★
62% · 28/45 Questions
✓ Free question

Five short MCQs on one CREATE TABLE snippet. The keys: degree = number of columns (3); name is a column; SQL keywords are case-insensitive so the odd-looking SelecT * fROM runs and shows headers + rows; the multi-row INSERT repeats the keyword VALUES so it errors; and the DELETE is missing FROM, so it errors and no row is deleted.

The snippet under discussion:

CREATE TABLE student (
    name CHAR(30),
    student_id INT,
    gender CHAR(1),
    PRIMARY KEY (student_id)
);

a) Degree of the student table

The degree of a relation is its number of attributes (columns). Here there are exactly three: name, student_id, gender — the PRIMARY KEY (student_id) line is a constraint, not a fourth column.

  • (i) 30 is just the size of CHAR(30); (ii) 1 confuses degree with the single key column; (iv) 4 wrongly counts the constraint line.
  • Correct: (iii) 3.

b) What does name represent?

name is declared inside CREATE TABLE with a data type (CHAR(30)), which is precisely how a column is defined.

  • (i) the table is student; (ii) rows only come into existence via INSERT; (iv) a database is created by CREATE DATABASE.
  • Correct: (iii) a column.

c) SelecT * fROM student;

SQL keywords are case-insensitive, so this strange capitalisation is perfectly legal — option (iii) "error" is out. SELECT * retrieves every column of every row, and the client displays the result as a table with the column names as headers above the contents:

SelecT * fROM student;
namestudent_idgender
.........

So the most precise option is the one that mentions both the column names and the contents — (i) is incomplete, (iv) is the opposite of what happens.

  • Correct: (ii) Displays column names and contents of table 'student'.

d) The multi-row INSERT

INSERT INTO student
VALUES ("Suhana",109,'F'),
VALUES ("Rivaan",102,'M'),
...

The keyword VALUES may appear only once; the row tuples after it are separated by commas alone. Repeating VALUES before every row is a syntax error, so the statement fails immediately. (Even after fixing the syntax it would still fail: student_id 109 appears twice — "Suhana" and "Shaurya" — violating the primary key with ERROR 1062: Duplicate entry '109'.) The correct multi-row form, for reference:

INSERT INTO student VALUES
('Suhana', 109, 'F'),
('Rivaan', 102, 'M'),
('Atharv', 103, 'M'),
('Rishika', 105, 'F'),
('Garvit', 104, 'M');
  • (ii)/(iv) claim success, which the syntax rules out; (iii) is a distractor — SQL syntax validity does not "depend on compiler".
  • Correct: (i) Error.

e) DELETE student WHERE student_id=109;

The statement is missing the keyword FROM — the valid form is DELETE FROM student WHERE .... As written it is a syntax error, the statement never executes, and therefore no row is deleted.

  • (i)/(iv) assume the query runs; (ii) describes what the corrected query would do — and even then, since student_id is the primary key, at most one row can hold 109.
  • Correct: (iii) No row will be deleted.
✓Final answer

a) (iii) 3 — degree = number of columns.

b) (iii) a column — declared with type CHAR(30).

c) (ii) Displays column names and contents — keywords are case-insensitive; the result shows headers plus rows.

d) (i) Error — VALUES must appear only once (and 109 is duplicated anyway).

e) (iii) No row will be deleted — FROM is missing, so the statement errors out.

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.