Here are 1000 MySQL MCQ (Chapterwise).
1. What is MySQL?
a) An operating system
b) A relational database management system (RDBMS)
c) A programming language
d) A web server
View Answer
Explanation: MySQL is a relational database management system (RDBMS) used for managing and storing data.
2. What does “MySQL” stand for?
a) My Sequence Query Language
b) My Structured Query Language
c) Mine Sequence Query Language
d) My Special Query Language
View Answer
Explanation: “MySQL” stands for “My Structured Query Language,” combining “My,” the co-founder’s daughter’s name, with SQL (Structured Query Language).
3. Who developed MySQL?
a) MySQL AB
b) Microsoft
c) Oracle Corporation
d) Sun Microsystems
View Answer
Explanation: MySQL was originally developed by MySQL AB, a Swedish company.
4. Which type of database management system is MySQL?
a) Network
b) Object-oriented
c) Relational
d) Hierarchical
View Answer
Explanation: MySQL is a ‘relational’ DBMS. It is efficient at relating data in two different tables and joining information from them. Hierarchical and Network DBMS are based on parent-child relationships of records. Object-oriented DBMS use objects to represent models.
5. Which of the following best describes the purpose of MySQL?
a) To store and retrieve data
b) To create user interfaces
c) To build websites
d) To manage file systems
View Answer
Explanation: MySQL is used to store and retrieve data in structured formats through SQL queries.
6. Which query language does MySQL use?
a) NoSQL
b) JavaScript
c) Structured Query Language (SQL)
d) MongoDB Query Language
View Answer
Explanation: MySQL uses SQL (Structured Query Language) to interact with the database.
7. Which is the MySQL instance responsible for data processing?
a) MySQL server
b) SQL
c) MySQL client
d) Server daemon program
View Answer
Explanation: MySQL uses client-server architecture. The MySQL server program runs on the machine where databases are stored. SQL is a query language used for querying the tables and information retrieval.
8. MySQL is commonly used as the database component in which software stack?
a) LAMP
b) MERN
c) JAM
d) MEAN
View Answer
Explanation: MySQL is commonly used as the database in the LAMP stack (Linux, Apache, MySQL, PHP/Perl/Python).
9. How are identifiers quoted in MySQL?
a) double quotes
b) backticks
c) can’t be quoted
d) single quotes
View Answer
Explanation: An identifier is quoted within the backtick characters ‘`’. This allows use of any character except a byte with value 0 or 255. Single quotes and double quotes are not allowed when quoting identifier names.
10. Which of the following is case sensitive in MySQL?
a) Column names
b) Event names
c) Logfile group names
d) Indexes
View Answer
Explanation: Column names and indexes are not case sensitive on any platform and neither are column aliases. Unlike the standard SQL, the names of the log file groups are always case sensitive.
11. What is ‘xyz’ in the following SQL statement?
SELECT abc FROM xyz;
a) database name
b) row name
c) table name
d) column name
View Answer
Explanation: The SELECT clause is used to retrieve information from some specified tables. It follows a specified format for information retrieval. Here, ‘abc’ can be a column name. It must be present in the table ‘xyz’.
12. Which storage engine enables to access tables from a MySQL server managed by another server?
a) MyISAM
b) FEDERATED
c) EXAMPLE
d) InnoDB
View Answer
Explanation: There are many storage engines that are used in MySQL. By default, MyISAM is used as the storage engine unless specified otherwise. FEDERATED enables access to a foreign MySQL server.
13. What is data in a MySQL database organized into?
a) Tables
b) Networks
c) Objects
d) File systems
View Answer
Explanation: Since MySQL is an RDBMS, its data is organized in tables for establishing relationships. A table is a collection of rows and columns, where each row is a record and columns describe the features of records.
14. Which operator is used to perform integer divisions in MySQL?
a) /
b) DIV
c) \
d) //
View Answer
Explanation: The operator ‘DIV’ is used to perform integer divisions in MySQL. ‘//’ is used in languages like Python to do the same. The operator ‘/’ performs floating point divisions and ‘\’ facilitates escape sequences.
15. Which of the following options tells MySQL to ask for entering the password?
a) -u
b) -p
c) -h
d) -e
View Answer
Explanation: The command ‘mysql -p’ (alternative form: –password) prompts for the password. ‘-h’ (alternative form: –host) specifies the host where the MySQL server is running. ‘-u’ is for specifying the username.
16. Which statement can be used to specify the sql_mode system variable at runtime?
a) ASSIGN
b) SET
c) CHANGE
d) SPECIFY
View Answer
Explanation: The ‘SET’ statement can change the SQL mode at runtime. For example, the statement SET sql_mode = ‘ANSI_QUOTES’ can be used by a client in its own session-specific SQL mode.
17. The command to move the cursor to the beginning of line in MySQL input editor is?
a) Ctrl-E
b) Ctrl-A
c) Ctrl-D
d) Esc-a
View Answer
Explanation: Control-A moves the cursor to the beginning of the line. Ctrl-E moves the cursor to the end of the line. Control-D deletes the character under the cursor, whereas Esc-a is not valid.
18. Which of the following does not support a materialized view?
a) PostgreSQL
b) Oracle
c) MySQL
d) SybaseSQL
View Answer
Explanation: In MySQL, ‘Views’ are treated a little differently than Oracle, PostgreSQL, and SybaseSQL since they support materialized views, and MySQL does not use the materialized view.
19. What is x in the following MySQL statement?
DELETE FROM x USING x LEFT JOIN y ON x.col = y.col;
a) column name
b) server name
c) database name
d) table name
View Answer
Explanation: The ‘DELETE’ operation is being performed in the statement. The table names are ‘x’ and ‘y’. The column name is ‘col’. The rows from the left join of x and y get deleted according to the condition given.
20. Which command is used for taking “server side help” in MySQL command line tool?
a) /h
b) /c
c) /e
d) None of the mentioned
View Answer
Explanation: /h represents help contents for MySQL.
21. What is the role of “CONSTRAINTS” in defining a table in MySQL?
a) Declaring Foreign Key
b) Declaring primary key
c) Restrictions on columns
d) All of the mentioned
View Answer
Explanation: Constraints are used to apply various restrictions and define key attributes on columns when designing a table, such as primary key, foreign key, and other conditions.
22. Which Clause is used to select a particular table in MySQL?
a) ALTER
b) SELECT
c) FROM
d) WHERE
View Answer
Explanation: The ‘FROM’ clause in SQL specifies the table from which to retrieve data in a SELECT statement.
23. Which data type is used to store data and time in MySQL?
a) Temporal data type
b) Char/Varchar
c) Text data type
d) Numeric data type
View Answer
Explanation: Temporal data types are used for storing Date, Time, Timestamp, or Datetime in MySQL.
24. What is def in the following MySQL statement?
CREATE TRIGGER abc (...) (...) ON def FOR EACH ROW ghi;
a) trigger name
b) table name
c) trigger statement
d) update statement
View Answer
Explanation: The trigger creation construct in MySQL is the ‘CREATE TRIGGER’ construct. It specifies components like the trigger name, the type of statement for which it is activated, and the table name and statement.
25. To check how MySQL would execute a SELECT query, which statement is used?
a) EXPLAIN
b) SHOW
c) DISPLAY
d) TELL
View Answer
Explanation: In MySQL, by issuing an EXPLAIN statement, MySQL displays some information about how it would execute a SELECT query without actually executing it. It is prefixed with the query.
26. Which of the following are the valid “database datatypes” in MySQL?
a) Temporal
b) Numerical
c) All of the mentioned
d) Text
View Answer
Explanation: None.
27. What is the meaning of “EMPTY SET” in the following MySQL command?
SELECT fname, lname, person_id FROM person WHERE lname=’s’; /* after Execution*/ Mysql tool RETURNS EMPTY SET 0:00sec
a) Access denied
b) No values
c) Error
d) None of the mentioned
View Answer
Explanation: “EMPTY SET” means there were no values stored in the structure that belongs to lname.
28. Which of these is not used to connect to the MySQL server?
a) mysqlcheck
b) mysql
c) mysqladmin
d) mysql_upgrade
View Answer
Explanation: mysql_upgrade is used after a MySQL upgrade operation. It checks tables for incompatibilities and repairs them if necessary. It updates the grant tables with any changes that have been made in newer versions of MySQL.
29. Which of the following can be used interchangeably with MYSQL_VERSION_ID?
a) MYSQL_VERSION_ID
b) MYSQL_ID
c) LIBMYSQL_VERSION
d) LIBMYSQL_VERSION_ID
View Answer
Explanation: The ‘LIBMYSQL_VERSION’ and ‘LIBMYSQL_VERSION_ID’ macros have the same values as ‘MYSQL_SERVER_VERSION’ and ‘MYSQL_VERSION_ID,’ and the two sets of macros can be used interchangeably.
30. Which mode prevents MySQL from performing a full check of date parts?
a) ALLOW_DATES_INVALID
b) STOP_DATES_CHECK
c) PREVENT_DATE_CHECK
d) ALLOW_INVALID_DATES
View Answer
Explanation: In MySQL, it is also possible to selectively weaken the strict mode in some places. If the ALLOW_INVALID_DATES SQL mode is enabled, MySQL doesn’t perform full checking of the date parts.
31. What is the most important configurable resource for MyISAM?
a) speed cache
b) time cache
c) key cache
d) memory cache
View Answer
Explanation: For index processing, ‘MyISAM’ manages its own key cache, which is the most important configurable resource for the MyISAM storage engine. It is used for index-based retrievals and sorts.
32. Which upgrade involves exporting existing data using mysqldump?
a) logical
b) inplace
c) system
d) illogical
View Answer
Explanation: The in-place upgrade involves shutting down the old MySQL version, replacing the old MySQL binaries or packages with the new ones, restarting MySQL on the existing data directory, and running mysql_upgrade.
33. What enables read and execute access to all users outside of the MySQL group?
a) drwxrwxr-x
b) drwxrwxr-y
c) drwyrwyr-y
d) drwyrwyr-x
View Answer
Explanation: Some database directories have the proper permissions like ‘drwx’, which enables read, write, and execute access to the owner but no access to anyone else. Other directories have an overly permissive access mode like ‘drwxrwxr-x’.
34. What is the hub of a MySQL installation?
a) mysqlc
b) mysqld
c) mysqla
d) mysqlb
View Answer
Explanation: The server, mysqld, is the hub of a MySQL installation; it performs all manipulation of databases and tables. On Unix, several related scripts are available to assist in server startup.
35. Where does MySQL Enterprise Backup record details of each backup?
a) backup_history
b) backlog_history
c) history_backup
d) history_backlog
View Answer
Explanation: The restored data includes the ‘backup_history’ table, where ‘MySQL Enterprise Backup’ records details of each backup. This table allows for future incremental backups using ‘–incremental-base=history:last_backup’.
36. Which of the following is not a valid MySQL aggregate function?
a) MAX
b) COUNT
c) ADD
d) AVG
View Answer
Explanation: ADD is not an aggregate function. MySQL aggregate functions include COUNT, MAX, MIN, AVG, and SUM.
37. Which classes do spatial data types in MySQL correspond to?
a) ClosedGIS
b) ClosedGSS
c) OpenGIS
d) OpenGSS
View Answer
Explanation: MySQL has spatial data types that correspond to OpenGIS classes. Some of them that hold single geometry values are ‘GEOMETRY’, ‘POINT’, ‘LINESTRING,’ and ‘POLYGON’. Some can hold a collection of values.
38. What does mysql_fetch_row() return?
a) integer
b) pointer
c) structure
d) float
View Answer
Explanation: ‘mysql_fetch_row()’ returns a MYSQL_ROW value, a pointer to an array of values. If the return value is assigned to a variable named row, each value within the row is accessed as row[i].
39. What is the meaning of the “SELECT” clause in MySQL?
a) Show me all rows
b) Show me all columns
c) Show me all Columns and rows
d) None of the mentioned
View Answer
Explanation: None.
40. Which MySQL clause is used to combine rows from two or more tables?
a) JOIN
b) COMBINE
c) MERGE
d) UNION
View Answer
Explanation: The JOIN clause is used to combine rows from multiple tables based on a related column.
41. What will be the result of the following MySQL command?
SELECT emp_id, ‘ACTIVE’ AS STATUS, emp_id * 3.14 AS emp_pi, UPPER (lname) AS last_name FROM employee;
a) emp_id, ACTIVE, emp_id * 314, UPPER(lname)
b) emp_id, Status, emp_pi, last_name
c) Error
d) None of the mentioned
View Answer
Explanation: Status, emp_pi, last_name are “column aliases” and Keyword “AS” is optional.
42. What will be the output of the following MySQL statement “true AND Null”?
a) Null
b) True
c) None of the mentioned
d) Depend
View Answer
Explanation: None.
43. Which clause is similar to the “HAVING” clause in MySQL?
a) FROM
b) WHERE
c) SELECT
d) None of the mentioned
View Answer
Explanation: “WHERE” is also used to filter the row values in MySQL.
44. Which of the following MySQL data types can hold large amounts of data such as text?
a) INT
b) ENUM
c) BLOB
d) VARCHAR
View Answer
Explanation: BLOB (Binary Large Object) is a data type in MySQL that can hold large amounts of binary data, such as images or videos.
45. What does the function mysql_num_rows() return?
a) A pointer to the result set
b) The number of rows in a result set
c) The current row in a result set
d) The number of columns in a result set
View Answer
Explanation: The function mysql_num_rows() returns the number of rows in the result set.
46. What will be the order of sorting in the following MySQL statement?
SELECT emp_id, emp_name FROM person ORDER BY emp_id, emp_name;
a) Sorting {emp_name, emp_id}
b) None of the mentioned
c) Sorting {emp_id, emp_name}
d) Sorting {emp_id} but not emp_name
View Answer
Explanation: In the query, first “emp_id” will be sorted, then “emp_name” with respect to “emp_id.”
47. What does the function mysql_fetch_assoc() return?
a) Array of associative key-value pairs
b) Array of indexed values
c) Boolean value
d) String
View Answer
Explanation: mysql_fetch_assoc() returns an associative array where the keys are the column names.
48. Which privileges are required on the source server to use mysqldbcopy?
a) UPDATE
b) CREATE
c) SELECT
d) INSERT
View Answer
Explanation: To use the utility program ‘mysqldbcopy’, the user must have SELECT privileges for the database(s) on the source server and have CREATE, INSERT, and UPDATE on the destination server.
Chapterwise Multiple Choice Questions on MySQL
- General MySQL Use
- Using SQL to Manage Data
- Data Types
- Stored Programs
- Query Optimization
- MySQL Programming
- MySQL Programs Using C
- MySQL Programs Using Perl DBI and PHP
- MySQL Administration
- MySQL Data Directory
- General MySQL Administration
- Access Control and Security
- Database Maintenance, Backups and Replication
- Data Type Reference, Operators and Functions
- System, Status and User Variables
- SQL Syntax
- Select Statement
- Nulls and Conditions and Miscellaneous
1. General MySQL Use
The section contains multiple choice questions and answers on database terminology, mysql setup and interactions.
|
|
2. Using SQL to Manage Data
The section contains questions and answers on server sql mode, mysql identifiers and rules, sql statements case sensitivity, selecting, creating, dropping and altering databases, table retrievals with joins, union and subqueries, views, transactions, foreign key, table creation, populating and modifying tables.
3. Data Types
The section contains MCQs on data value categories, datatypes, sequences and type conversions.
4. Stored Programs
The section contains multiple choice questions and answers on compound statements, stored functions, triggers, events and security.
|
|
5. Query Optimization
The section contains questions and answers on indexing, query optimizer, choosing and loading data types, scheduling and locking issues, administrative level optimizations, query mechanics and clauses.
6. MySQL Programming
The section contains MCQs on mysql programs and apis.
|
|
7. MySQL Programs Using C
The section contains multiple choice questions and answers on compiling and linking client programs, server connection, error handling, processing sql statements, embedded server library, multiple statement execution.
8. MySQL Programs Using Perl DBI and PHP
The section contains questions and answers on perl script characteristics, perl dbi and php overviews.
|
|
9. MySQL Administration
The section contains MCQs on mysql components and administration, access control and security, database maintenance, backups and replication.
|
|
10. MySQL Data Directory
The section contains multiple choice questions and answers on location, structure and relocating data directory’s.
|
|
11. General MySQL Administration
The section contains questions and answers on mysql installation and server startup, managing mysql user accounts, maintaining logs, server tuning, storage engine configuration, running multiple servers, internationalization and localization issues.
12. Access Control and Security
The section contains MCQs on secure connections, internal and external security.
|
|
13. Database Maintenance, Backups and Replication
The section contains multiple choice questions and answers on preventive maintenance principles, database backups, checking and repairing database tables, backups for data recovery and replication servers setting.
14. Data Type Reference, Operators and Functions
The section contains questions and answers on numeric, string and spatial data types, operators and functions.
|
|
15. System, Status and User Variables
The section contains MCQs on system and session only system variables, status and user defined variables.
|
|
16. SQL Syntax
The section contains multiple choice questions and answers on sql statement syntax, compound statement and comment syntax.
|
|
17. Select Statement
The section contains questions and answers on select clauses, from clauses, order by clauses, where clauses, group by and having clause.
|
|
18. Nulls and Conditions and Miscellaneous
The section contains MCQs on database copies, secure connections, conditional evaluation, null and condition types.
|
|
Wish you the best in your endeavor to learn and master MySQL!