MCQ

MYSQL MCQ and Answers – Part 5

MYSQL MCQs questions with answers to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are taken from an interview. So you will find questions on MySQL Database, SQL query, Data Model, and more. This MCQ will easily prepare anyone to pass their exam.
 

1. Which of the following command is used to drop an existing table?

A DROP TABLE

B DELETE

C Both A and B

D None of the above

A
DROP TABLE is used to drop an existing table.

 

 

2. Which of the following command is used to display all existing tables in a database?

A SHOW TABLES

B SHOW TABLE

C SHOW

D None of the above

A
SHOW TABLES is used to display all existing tables in a database.

 

 

3. Is duplicate primary key allowed in SQL?

A Yes

B No

C Depends on DBMS

D None of the above

B
Primary keys are used to uniquely define the attribute stored in the table.

 

 

4. Is duplication of attributes allowed in SQL?

A Yes

B No

C Depends on DBMS

D None of the above

A
Duplicate values are allowed but not for primary keys.

 

 

5. What is the correct format for storing date in SQL?

A DEC-01-1994

B 08-1994-12

C 08-DEC-16

D 1994-12-08

D
The correct format for storing the date is : AAAA-MM-JJ.

 

 

6. Which of following the following statement will produce an error?

A SELECT * FROM person WHERE person_id=1;

B SELECT lastname FROM person;

C SELECT lastname, firstname, person_id FROM person;

D None of the above

D

 

 

7. What key is used to link two tables in Mysql?

A Primary key

B Foreign key

C Primary and foreign key

D None of the above

B
The foreign key is the only key that can link two tables.

 

 

8. Find the error?
CREATE TABLE person ( 
   person_id SMALLINT,
   lastname VARCHAR,
   FIRSTNAME VARCHAR,
   birth_date DATE
   CONSTRAINTS pk_person PRIMARY KEY (person_id)
);

INSERT INTO 
personne( person_id, lastname, FIRSTNAME, Birth_date )
VALUES(1,’a’,’b’, 09-1994-02);

A Error in data values

B No Error

C Other error

D None of the above

A
The format of the data type “DATE” is YYYY-MM-DD.

 

 

9. Find the error?
CREATE TABLE person ( 
   person_id SMALLINT,
   lastname VARCHAR,
   FIRSTNAME VARCHAR,
   birth_date DATE
   CONSTRAINTS pk_person PRIMARY KEY (person_id)
);

INSERT INTO 
person( person_id, lastname, FIRSTNAME)
VALUES(1, ’a’, ’b’);

INSERT INTO 
person( person_id, lastname, FIRSTNAME)
VALUES(1,’c’,’d’);

A No Error

B Error, duplicate value

C Other error

D None of the above

B
The primary key can never have the same value.

 

 

10. What are the valid data types in Mysql?

A Numeric

B Temporary

C Text

D All the answers are true

D

 

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

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