Tricky MySQL Questions and Answers focuses on “Database Maintenance, Backups and Replication”.
1. For InnoDB tables in mysqldump an online backup that takes no locks on tables can be performed by ______________
a) –multiple-transaction
b) –single-transaction
c) –double-transaction
d) –no-transaction
Answer: b
Clarification: For InnoDB tables it is possible to perform an online backup that takes no locks on tables using the option ‘–single-transaction’ to ‘mysqldump’. The ‘mysqldump’ can make backups.
2. To reload a delimited text data file use ______________
a) mysqldump
b) mysqld
c) mysqlimport
d) mysqlnaive
Answer: c
Clarification: A way to create text data files along with files containing ‘CREATE TABLE’ statements for the backed up tables is to use ‘mysqldump’ with –tab. To reload a delimited text data file ‘mysqlimport’ is used.
3. Replication enables data from one MySQL database server to be copied to one or more MySQL database servers.
a) True
b) False
Answer: a
Clarification: Replication enables data from one MySQL database server (the master) to be copied to one or more MySQL database servers (the slaves). Replication is asynchronous by default.
4. SBR replication is ______________
a) Statement based
b) Row based
c) Column based
d) Table based
Answer: a
Clarification: There are two main kinds of replication format: Statement Based Replication (SBR) replicates entire SQL statements and Row Based Replication (RBR) replicates only the changed rows.
5. The library file that contains various portability macros and definitions is ______________
a) my_global.h
b) my_sys.h
c) mysql.h
d) my_local.h
Answer: b
Clarification: The ‘my_sys.h’ header file contains a variety of portability macros and definitions required for structures and functions. These structures and functions are used by the client library.
6. The header that should be included first is ______________
a) my_global.h
b) my_sys.h
c) mysql.h
d) my_local.h
Answer: a
Clarification: The file ‘my_global.h’ takes care of including several other header files that are likely to be generally useful, like ‘stdio.h’. It also includes Windows compatibility information.
7. Which of the following use ‘NULL’ to indicate failure?
mysql_init(), mysql_real_connect()
a) 0
b) 1
c) 2
d) 3
Answer: c
Clarification: Both of the client library routines named ‘mysql_init()’ and ‘mysql_real_connect()’ return a pointer to the connection handler in order to indicate success and NULL to indicate failure.
8. Which of the following does not return a value?
mysql_close(), mysql_init, mysql_real_connect
a) 0
b) 1
c) 2
d) 3
Answer: b
Clarification: It is not necessary that every Application Programming Interface call would return a value. For example, the client routine named ‘mysql_close()’ returns void, that is, it does not return a value.
9. What is the general statement-issuing routine?
a) mysql_real_query()
b) mysql_query_real()
c) mysql_image_query()
d) mysql_query_image()
Answer: a
Clarification: The general statement-issuing routine is mysql_real_query(). The statement is provided as a counted string (a string plus a length). The length of the statement string must be kept track of.
10. The most restrictive among the following is ______________
mysql_query(), mysql_real_query()
a) mysql_query()
b) mysql_real_query()
c) same
d) machine dependent
Answer: a
Clarification: The statement-issuing function other than ‘mysql_real_query()’ is ‘mysql_query()’. It is more restrictive in what it allows in the statement string although it is often easier to use.
