MCQ

MYSQL MCQ and Answers – Part 2

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 statement does not use the same number of bytes and the byte usage depends on the input data?

A Varchar

B Char

C Both Varchar and Char

D None of the above

A
With Varchar type, the length is variable, but the maximum is specified when creating a table. The maximum length can range from 0 to 255 bytes (before MySQL 5.0.3) or from 0 to 65,535 bytes in later versions. If a multibyte character set is used, the upper limit is 21,844 bytes.

 

 

2. The maximum length of a column of type “char” is _______?

A 255 bytes

B 65, 535 bytes

C 256 bytes

D None of the above

A
The length is fixed and indicates the number of characters declared when creating a table. This can be a value between 0 and 255 bytes.

 

 

3. To create a database only if it does not already exist, which clause is used?

A IF EXISTS

B IF NOT EXISTS

C CREATE EXISTS

D EXISTS IF

B
CREATE DATABASE statement supports many optional values. To create a database named ‘my_db’ only if it does not exist, we write CREATE DATABASE IF NOT EXISTS my_db.

 

 

4. Is it possible to write COLLATE expression without CHARACTER SET?

A True

B False

A
Collation refers to a set of rules that determine how data is sorted and compared. Data of type “char” is sorted using rules defining the correct character sequence, with options to specify case sensitivity, accent marks, character types and character widths.

When creating a database, the values ‘CHARACTER SET’ and ‘COLLATE’ are specified. When ‘CHARACTER SET’ is given without ‘COLLATE’, the default collation is used.

Example : Let’s say we have this query:

SELECT *
FROM my_table
WHERE city = 'Alex Jose'

 
To include Alex José (with the accent [é]) we use “COLLATE utf8_general_ci”:

SELECT *
FROM my_table
WHERE city COLLATE utf8_general_ci = 'Alex José'

 

 

5. MySQL stores database character sets and collation attributes in ____ file?

A dp.opt

B db.opt

C db.sv

D db.zip

B
The file named ‘db.opt’ has a great importance for MySQL, especially MySQL server. It stores the database attributes with the db charset and collation attributes.

 

 

6. What does “salary” represent in the following query?
CREATE TABLE demo_tbl
(
  id number not null,
  salary number(9,3),
  hiring_date DATE,
  birth_date DATE
)

A Table

B Row

C Column

D Object

C
‘Id’, ‘salary’, ‘hiring_date’ and ‘birth_date’ are the attributes or columns of the ‘demo_tbl’ table. CREATE TABLE statement in SQL creates a table, assigns it a name and its attributes, and specifies the type of attributes used in the table.

 

 

7. Which MySQL instance is responsible for processing the data?

A MySQL client

B MySQL server

C SQL

D Daemon program

B
MySQL uses the client-server architecture. MySQL server runs on the machine where the databases are stored. SQL is a query language used to query tables and get information.

 

 

8. What is the program that represents MySQL server?

A mysqla

B mysqlb

C mysqlc

D mysqld

D
mysqld is the MySQL server program. It responds to incoming client requests by accessing the database. MySQL implements a client/server architecture in which mysqld is the server program.

 

 

9. What statement is used to show the definition of an existing database?

A SHOW CREATE DATABASE

B SHOW DATABASE

C SHOW CREATE

D SHOW CREATE DATABASE TABLE

A
The statement “SHOW CREATE DATABASE” is used to show the definition of an existing database in MySQL server. It is followed by the qualified name of the database.

 

 

10. In MySQL databases, the structure representing the organizational views of all databases is _________ ?

A Schema

B View

C Instance

D Table

A
In a database, the Schema gives the structure of the database. A view is an object that can be generated with a query. A table is a collection of records. An instance is like a class object.

 

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 *