250+ TOP MCQs on When Good Statements Go Bad and Answers

MySQL Multiple Choice Questions on “When Good Statements Go Bad”

1. Which command is used to remove existing tables or database?
a) DROP TABLE
b) DELETE
c) Either DROP TABLE or DELETE
d) None of the mentioned

Answer: a
Clarification: None.

2. Which command is used to display all the existing tables in a database?
a) SHOW TABLES
b) SHOW TABLE
c) SHOW
d) None of the mentioned

Answer: a
Clarification: None.

3. Is duplicate entry of primary key is allowed in SQL?
a) Yes
b) No
c) Depends
d) None of the mentioned

Answer: b
Clarification: Primary key are used to uniquely define attributed stored in the table.

4. Is duplicate entry of other attributes are allowed in SQL?
a) Yes
b) No
c) Depends
d) None of the mentioned

Answer: a
Clarification: Duplicate values are allowed but not for Primary Key attributes.

5. Which is the correct format to store date in the SQL?
a) DEC-01-1991
b) 01-1991-11
c) 01-DEC-12
d) 1991-11-01

Answer: d
Clarification: None.

6. Which of the following are the valid “database datatypes” in Mysql?
a) Numerical
b) Temporal
c) Text
d) All of the mentioned

Answer: d
Clarification: None.

7. Find the error in the following SQL statement?

CREATE TABLE person
( person_id SMALLINT, name VARCHAR, LAST VARCHAR
  CONSTRAINTS pk_person PRIMARY KEY (person_id));
  INSERT INTO person
  VALUES( person_id, name, LAST)
  (1, ’s’, ’p’);
  INSERT INTO person
  ( person_id, name, LAST)
  VALUES(1,’s’,’p’);

a) No error
b) Error, Duplicate value
c) Any other error
d) None of the mentioned

Answer: b
Clarification: Primary can never have same value.

  250+ TOP MCQs on Arranging for MySQL Server Startup and Shutdown

8. Find the error in the following SQL statement?

  CREATE TABLE person
  ( person_id SMALLINT, name VARCHAR, LAST VARCHAR, Bith_date DATE
  CONSTRAINTS pk_person PRIMARY KEY (person_id));
  INSERT INTO person
  VALUES( person_id, name, LAST, Birth_date)
  (1,’s’,’p’, 24-1991-01);

a) In correct data value
b) No error
c) Any other error
d) None of the mentioned

Answer: a
Clarification: Format for DATE datatype is YYYY-MM-DD.

9. Which Key is used to link two tables in Mysql?
a) Primary Key
b) Foreign Key
c) Both Primary and Foreign Key
d) None of the mentioned

Answer: b
Clarification: Foreign Key is only the Key which can link two tables.

10. Which line of the following statements will produce error?
a) SELECT * FROM person WHERE person_id=1;
b) SELECT pname FROM person;
c) SELECT pname, lname, person_id FROM person;
d) None of the mentioned

Answer: d

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top