Database MCQ Set 1
. Which of these is the most general purpose language?
a) C
b) Perl
c) Python
d) PHP
Answer
Answer: a [Reason:] C is a general purpose language, so in principle it can be used for anything. C tends to be used more often for standalone programs rather than for Web programming in practice.
2. Among the following, for which language is image processing least simple?
a) PHP
b) Perl
c) Python
d) C
Answer
Answer: d [Reason:] It is not as easy to perform text processing and memory management in C than it is in languages like Perl and PHP. These capabilities tend to be heavily used in the web applications.
3. The CGI.pm module for website development is a part of _______
a) Perl
b) Java
c) Python
d) C++
Answer
Answer: a [Reason:] Like C, Perl is also suitable for writing standalone programs. However, Perl is quite useful for Web site development. The CGI.pm module of Perl can be extensively used for it.
4. Compiled programs execute faster than interpreted scripts.
a) True
b) False
Answer
Answer: a [Reason:] For interpreted languages used in web development, the performance is better when the interpreter is invoked as a module which is a part of the Web server itself. Compiler is faster generally.
5. For a heavily used program, which of these languages should be preferred?
a) C
b) Perl
c) PHP
d) Python
Answer
Answer: a [Reason:] C is compiled while Perl and PHP are interpreted. So C programs generally will run faster than Perl or PHP scripts. Therefore C should be the best choice for a heavily used program.
6. The protocol CGI is _______
a) computer graphics interface
b) common graphics interface
c) computer gateway interface
d) common gateway interface
Answer
Answer: d [Reason:] The web server ‘Apache’ uses the interpreters as some CGI programs. This means that it communicates with these programs using the popular ‘Common Gateway Interface (CGI)’ protocol.
7. There is a startup penalty for a standalone interpreter.
a) True
b) False
Answer
Answer: a [Reason:] The startup penalty for a standalone interpreter makes it give at least an order of magnitude poorer performance than the module interpreter. Interpreters also have a setup cost.
8. Which of these has a bigger memory footprint?
Perl, PHP
a) Perl
b) PHP
c) same
d) machine dependent
Answer
Answer: a [Reason:] A clearly significant difference between Perl and PHP is that Perl has a bigger memory footprint than PHP. Apache processes are larger with ‘mod_perl’ linked in than with ‘mod_php’.
9. Which is the correct decreasing order for highly developed text manipulation capabilities?
a) Perl, PHP, C
b) Perl, C, PHP
c) PHP, Perl, C
d) C, PHP, Perl
Answer
Answer: a [Reason:] Perl has the most highly developed capabilities in terms of text manipulation, and PHP follows it in the order. C is very rudimentary by comparison. It has the least simplicity.
10. Which API provides the lowest level interface to the server?
a) C API
b) Perl
c) PHP
d) Python
Answer
Answer: a [Reason:] The C Application Programming Interface provides the lowest level interface to the server. It enforces the least policy. Therefore it provides the least amount of safety net.
Database MCQ Set 2
1. Which option is necessary to compile a C program havin math functions?
a) -lm
b) -ln
c) -lp
d) -lq
Answer
Answer: a [Reason:] To compile a program written in the C language, it is compiled by issuing the option ‘-lm’. The examples of some math functions found in ‘math.h’ are floor(), sqrt(), pow(), log().
2. The option for specifying the executable name while compiling with gcc is _______
a) -e
b) -o
c) -a
d) -b
Answer
Answer: b [Reason:] When a C program is compiled with gcc, the option -o is issued in order to specify the name of the executable that is created after compilation. The default name given is ‘a.out’.
3. Which file can be used to execute multiple compile statements?
a) makefile
b) dofile
c) putfile
d) pushfile
Answer
Answer: a [Reason:] The Makefile is used to write multiple commands in there. The file is executed by prefixing the command ‘make’ with the command to run the file script containing the statements.
4. Which flag is used to compile client programs that use MySQL header files?
a) -O
b) -I
c) -U
d) -A
Answer
Answer: b [Reason:] The ‘-I’ option is specified when the client programs are compiled that use the MySQL header files. The compiler can easily find these header files when the ‘-I’ option is used.
5. The MySQL clients are linked with _______
a) -lmysqlclient
b) -cmysqlclient
c) -dmysqlclient
d) -vmysqlclient
Answer
Answer: a [Reason:] MySQL clients should be linked using the ‘-lmysqlclient’ option in the link command. A ‘-L’ option is also need to be specified to tell the linker where to find the library for it.
6. On Unix, linking uses dynamic libraries by default.
a) True
b) False
Answer
Answer: a [Reason:] On Unix, the linking process uses the dynamic libraries by default. In order to link to the static client library instead, its path name should be added to the link command to do the job.
7. What can be used as an alternative to mysqlconfig?
a) pkg-config
b) dkg-config
c) rkg-config
d) qkg-config
Answer
Answer: a [Reason:] The ‘pkg-config’ statement can be used as an alternative to the ‘mysql_config’ statement for obtaining information like compiler flags or to link libraries required to compile some MySQL applications.
8. Which of these has a smaller memory footprint?
Perl, PHP
a) Perl
b) PHP
c) same
d) machine dependent
Answer
Answer: b [Reason:] A clearly significant difference between Perl and PHP is that Perl has a bigger memory footprint than PHP. Apache processes are larger with ‘mod_perl’ linked in than with ‘mod_php’.
9. The static C library client in Windows is _______
a) mysqlclient.lib
b) mysqlclient.lb
c) mysqlclient.lm
d) myclient.lib
Answer
Answer: a [Reason:] The code can be linked with either the dynamic or static C client library. On Windows, the static library is named ‘mysqlclient.lib’ and the dynamic library is named ‘libmysql.dll’.
10. Which of the following is used on Solaris?
a) gcc
b) clang
c) Sun Studio
d) FreeBSD
Answer
Answer: c [Reason:] The program ‘gcc’ is generally used on Unix. ‘clang’ is used on ‘OSX’ or ‘FreeBSD’. The ‘Sun Studio’ is used on Solaris. However, ‘gcc’ on Unix is a widely popular choice for client programs.
Database MCQ Set 3
1. Which of these return a result to the client?
a) Stored functions
b) Stored procedures
c) Triggers
d) Events
Answer
Answer: a [Reason:] Stored functions return a result from a calculation and can be used in expressions. Stored procedures do not return a result directly but can be used to perform general computations.
2. Which of these is defined to execute when the table is modified only?
a) Stored functions
b) Stored procedures
c) Triggers
d) Events
Answer
Answer: c [Reason:] In MySQL, triggers are associated with a table. They are defined to execute when the table is modified via INSERT, DELETE or UPDATE statements. MySQL supports objects to be stored on server side.
3. What executes on a time activated basis according to a schedule?
a) Stored program
b) Events
c) Triggers
d) Stored procedures
Answer
Answer: b [Reason:] In MySQL, the events execute on a time activated basis according to a schedule. Triggers are defined to execute when the table is modified via INSERT, DELETE or UPDATE statements.
4. Stored programs improve database security.
a) True
b) False
Answer
Answer: a [Reason:] Stored programs improve database security because controlled access can be enabled to sensitive data by appropriate selection of the privileges a program has when it executes.
5. Which character does the mysql client program recognize as a statement delimiter?
a) :
b) .
c) ;
d) ,
Answer
Answer: c [Reason:] By default, mysql itself recognizes the semicolon as a statement delimiter, so the delimiter must be redefined temporarily to cause mysql to pass the entire stored program definition to the server.
6. Which command is used to redefined the mysql delimiter?
a) redefine_delim
b) delim_redefine
c) delimiter
d) redefine
Answer
Answer: c [Reason:] To redefine the mysql delimiter, the delimiter command is used. A delimiter is a sequence of characters. It specifies the boundary between the separate regions in data streams.
7. Which of the following characters cannot be used as a delimiter?
a) ,
b) .
c) ;
d)
Answer
Answer: d [Reason:] In MySQL, the character backslash character is reserved for specifying escape sequences. For example, the escape sequence ‘t’ specifies a tab space character. It cannot be used as a delimiter.
8. Stored routines refers to stored functions and procedures.
a) True
b) False
Answer
Answer: a [Reason:] In MySQL, the stored routines is a limited term. It refers only to the stored functions and procedures. Both types of objects are defined using the similar syntax and are discussed together.
9. Stored programs refer to stored objects of how many of the following types?
functions, procedures, triggers, events
a) 0
b) 1
c) 3
d) 4
Answer
Answer: d [Reason:] In MySQL, the “stored programs” refers collectively to the stored objects of all types, namely, the functions, procedures, triggers, and events. They improve database security.
10. Which of the following statements does not modify the table?
a) INSERT
b) UPDATE
c) DELETE
d) SELECT
Answer
Answer: d [Reason:] In MySQL, the ‘SELECT’ statement is used to display the tables or their components according to some specified conditions and clauses. It does not modify the table unlike the others.
Database MCQ Set 4
1. Which library file contains various portability macros and definitions?
a) my_global.h
b) my_sys.h
c) mysql.h
d) my_local.h
Answer
Answer: b [Reason:] 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.
2. Which header should be included first?
a) my_global.h
b) my_sys.h
c) mysql.h
d) my_local.h
Answer
Answer: a [Reason:] 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.
3. mysql_init() returns a _______
a) integer
b) float
c) structure
d) pointer to a structure
Answer
Answer: d [Reason:] When NULL is passed to mysql_init() it automatically allocates a MYSQL structure, initializes it, and returns a pointer to it. The MYSQL data type is a structure containing information about a connection.
4. When linking to a static MySQL C client library, the client library and the client application must use the same compiler option.
a) True
b) False
Answer
Answer: a [Reason:] Generally, when linking to a static MySQL C client library, the client library and the client application must use the same compiler option when it is required to link the C runtime.
5. Which of these can be used in place of MYSQL_SERVER_VERSION?
a) LIBMYSQL_VERSION
b) LIBMYSQL_VERSION_ID
c) MYSQL_VERSION_ID
d) MYSQL_ID
Answer
Answer: a [Reason:] The macros ‘LIBMYSQL_VERSION’ and ‘LIBMYSQL_VERSION_ID’ have the same values as ‘MYSQL_SERVER_VERSION’ and ‘MYSQL_VERSION_ID’ and the two sets of macros can be used in place of each other.
6. Which of the following can be used interchangeably with MYSQL_VERSION_ID?
a) LIBMYSQL_VERSION
b) LIBMYSQL_VERSION_ID
c) MYSQL_VERSION_ID
d) MYSQL_ID
Answer
Answer: b [Reason:] 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.
7. Which option is supplied to ensure TCP/IP connection to local server?
a) –localhost
b) –host
c) –hostlocal
d) –connectlocal
Answer
Answer: b [Reason:] In order to ensure that the client makes a TCP/IP connection to the local server, the ‘–host’ or ‘-h’ option is used to specify a host name value of 127.0.0.1 or the IP address of the local server.
8. Connections to remote servers always use TCP/IP.
a) True
b) False
Answer
Answer: a [Reason:] The connections to remote servers always use TCP/IP. To connect to the server running on remote.example.com using the default port number (3306) this command is used: mysql –host=remote.example.com.
9. The –protocol value ‘TCP’ runs on which operating systems?
a) all
b) unix only
c) windows only
d) none
Answer
Answer: a [Reason:] The connection protocol used by the option ‘–protocol = TCP’ indicates TCP/IP connection to the local or the remote server. Each –protocol value has the set of permissible OS.
10. The ‘SOCKET’ protocol is permitted on which operating systems?
a) all
b) unix only
c) windows only
d) none
Answer
Answer: b [Reason:] The connection protocol used by the option ‘–protocol = SOCKET’ indicates the unix socket file connection to the local server. Each –protocol value has the set of permissible OS.
Database MCQ Set 5
1. Which of these is a stored program associated with a schedule?
a) Trigger
b) Event
c) Stored function
d) Stored procedure
Answer
Answer: b [Reason:] The MySQL version 5.1.6 and above has an event scheduler. It enables to perform time activated database operations. An event is a stored program that is associated with a schedule.
2. The event scheduler does not run by default.
a) True
b) False
Answer
Answer: a [Reason:] The event scheduler does not run by default, so you it must be turned on if events are to be used. An event is a stored program that is associated with a schedule to perform database operations.
3. Which of the following lines is used to turn on the event scheduler?
a) event_scheduler = ON
b) eventscheduler = ON
c) event_scheduler_ON
d) events_scheduler_ON
Answer
Answer: a [Reason:] The line ‘event_scheduler = ON’ is put in the option file that the server reads. The event scheduler does not run by default. It must be turned on if events are to used in the database.
4. Which statement is used to check the status of the event scheduler at runtime?
a) SHOW STATUS OF ‘event_scheduler’
b) SHOW VARIABLES OF ‘event_scheduler’
c) SHOW STATUS LIKE ‘event_scheduler’
d) SHOW VARIABLES LIKE ‘event_scheduler’
Answer
Answer: d [Reason:] In MySQL, in order to check the status of the event scheduler at runtime, the statement: SHOW VARIABLES LIKE ‘event_scheduler’; is used. The event_scheduler is a system variable.
5. Which value of event_scheduler enables checking status but not changing it at runtime?
a) ON
b) OFF
c) DISABLED
d) ENABLED
Answer
Answer: c [Reason:] In MySQL, if the event_scheduler is set to ‘DISABLED’ at startup, its status cannot be changed but can be checked at runtime. The events can be created but they will not execute.
6. If the scheduler is stopped, no events run.
a) True
b) False
Answer
Answer: a [Reason:] In MySQL, if the event scheduler is stopped, no events are run. It is also possible to leave the scheduler running but disable the individual events. This can be done with ‘DISABLED’.
7. Which log does the event scheduler log to?
a) error
b) record
c) library
d) update
Answer
Answer: a [Reason:] In MySQL, the event scheduler writes to the error log of the server, which can be checked for information about what the scheduler is doing. It logs the events as it runs them.
8. Which clause specifies periodic execution at fixed intervals?
a) EVERY
b) ALL
c) AT
d) ALTERNATE
Answer
Answer: a [Reason:] The ‘EVERY n interval’ clause specifies the periodic execution at fixed intervals. The interval values are like those used for the DATE_ADD() function, such as HOUR, DAY or MONTH.
9. To create or drop events for a database, which privilege should be granted?
a) CREATE
b) DROP
c) PRIVILEGE
d) EVENT
Answer
Answer: d [Reason:] In MySQL, all events belong to some database, so the EVENT privilege must be granted for that database in order to both create or drop the events for it. An event is a stored program.
10. The default definer of an event is the user who ___
a) created the database
b) created the event
c) created the table
d) created the column
Answer
Answer: b [Reason:] Unless the event has been altered, the default definer of an event is the user who created the event. In this case, the definer is the one who called the last ‘ALTER EVENT’ statement.