Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 14

Sun 310-812

Version

QUESTION NO: 1
You want to create two databases, test and Test. Which of the following statements
is true?

A. You can create both databases because database names in MySQL are case
sensitive.
B. You can create both databases when your operating system supports case sensitive
directory names.
C. You can create both databases when you quote delimited the database names like
`test` and `Test`.
D. You can create both databases since t and T are different in the ASCII character
set.
Answer: B

QUESTION NO: 2
Which of the following are a valid identifier for the user table in the mysql
database?

A. mysql.user
B. `mysql.user`
C. `mysql`.`user`
D. mysql.`user`
Answer: A,C,D

QUESTION NO: 3
Is the following statement true or false? "Each database corresponds to a single
directory under data directory, regardless of what storage engine table uses in the
database"

A. true
B. false
Answer: A

QUESTION NO: 4
Which of the following statements are true? Databases don't have a default
character set or collation.

A. Databases don't have a default character set or collation.


B. Database have a default character set and a default collation.
C. When creating a table within a database without specifying a character set and a
collation, the default character set and collation from the
database are being used.
D. If a default character set and collation are defined for a database, settings
for tables defined in that database will be ignored.
Answer: C,D

QUESTION NO: 5
Ignoring any warnings that may be issued, which of the following statements will
delete the `world` database and its entire contents on execution, but return no
error if it doesn't exist?
A. DROP DATABASE `world` IGNORE ERRORS
B. DROP IF EXISTS DATABASE `world`
C. DROP DATABASE IF EXISTS `world`
D. DELETE DATABASE `world` IGNORE ERRORS
E. DELETE IF EXISTS DATABASE `world`
F. DELETE DATABASE IF EXISTS `world`
Answer: C

QUESTION NO: 6
Which of the following statements will return a list of all of the databases with a
name that starts with 'pro'?

A. LIST DATABASES WHERE NAME LIKE 'pro%'


B. SHOW DATABASES WHERE NAME LIKE 'pro%'
C. SELECT DATABASES WHERE NAME LIKE 'pro%'
D. LIST DATABASES LIKE 'pro%'
E. SHOW DATABASES LIKE 'pro%'
F. SELECT DATABASES LIKE 'pro%'
Answer: E

QUESTION NO: 7
Which of the following statements will provide a list of all of the databases with
a name that starts with 'world'?

A. SELECT SCHEMA_NAME AS `Database` FROM INFORMATION_SCHEMA.SCHEMATA WHERE


SCHEMA_NAME LIKE 'world%'
B. SELECT SCHEMA_NAME AS `Database` FROM SCHEMATA_INFORMATION.SCHEMATA WHERE
SCHEMA_NAME LIKE 'world%'
C. SELECT NAME AS `Database` FROM INFORMATION_SCHEMA.DATABASE WHERE NAME LIKE
'world%'
D. SELECT NAME AS `Database` FROM SCHEMATA_INFORMATION.DATABASE WHERE NAME LIKE
'world%'
Answer: A

QUESTION NO: 8
Which of the following are true in relation to character set and collation
relationships in MySQL?

A. A collation may belong to only one character set.


B. A collation may belong to many character sets.
C. A character set may have only one collation.
D. A character set may have many collations.
Answer: A,D

QUESTION NO: 9
In non-strict mode, assuming that the table city does not already exist and you
execute the following sequence of commands: CREATE TABLE city (city_name CHAR(5))
INSERT INTO city (city_name) VALUES ('NEW YORK'), ('TOKYO'), (23+345), ('LONDON')
-- Ignoring any errors or warnings that may be issued, which values are now in the
table?

A. 'NEW YORK', 'TOKYO', '23+345', 'LONDON'


B. 'NEW Y', 'TOKYO', '23+34', 'LONDO'
C. 'NEW YORK', 'TOKYO', ' ', 'LONDON'
D. 'NEW Y', 'TOKYO', '368', 'LONDO'
E. 'NEW YORK', 'TOKYO', '368', 'LONDON'
Answer: D

QUESTION NO: 10
Consider the following: CREATE TABLE friends ( name VARCHAR(30) ) INSERT INTO
friends VALUES (' Tom ') SELECT name FROM friends Which of the quoted values below
will be returned for the name field in the SELECT results?

A. ' Tom'
B. ' Tom '
C. 'Tom'
D. 'Tom '
Answer: B

QUESTION NO: 11
Which statement(s) from following list are true for BINARY and VARBINARY data
types?

A. When BINARY values are stored, they are right-padded with null values to the
specified length
B. When VARBINARY values are stored, they are right-padded with null values to the
specified length
C. When BINARY values are retrieved, trailing nulls are removed
D. When VARBINARY values are retrieved, trailing nulls are removed
Answer: A,C

QUESTION NO: 12
Is the following statement true or false? "Fields with the DECIMAL column type are
always stored more efficiently than those with type FLOAT."

A. true
B. false
Answer: B

QUESTION NO: 13
Is the following statement true or false? "A 24-bit column can be specified with
BIT(24) in a CREATE statement."

A. true
B. false
Answer: A

QUESTION NO: 14
Is the following statement true or false? "VARCHAR columns usually require less
storage space than CHAR columns."

A. true
B. false
Answer: A

QUESTION NO: 15
Is the following statement true or false? "Math involving DOUBLE and FLOAT columns
is always accurate because MySQL 5 supports precision mathematics."
A. true
B. false
Answer: B

QUESTION NO: 16
Is the following statement true or false? "Defining a column as TIMESTAMP DEFAULT
CURRENT_TIMESTAMP will ensure that when rows are inserted, the current time will
always be used."

A. true
B. false
Answer: B

QUESTION NO: 17
Is the following a valid CREATE statement? CREATE TABLE pictures ( id INT
AUTO_INCREMENT NOT NULL, description VARCHAR(255) CHARACTER SET latin1 COLLATE
latin1_swedish_ci, image VARBINARY(17000) CHARACTER SET latin1 COLLATE latin1_bin,
PRIMARY KEY (id) )

A. Yes
B. No, the same collation must be used for all columns.
C. No, the parameter 17000 is invalid for the VARBINARY type.
D. No, the VARBINARY type may not have character set or collation attributes
Answer: D

QUESTION NO: 18
A column defined as DECIMAL, with no parameters, is equivalent to which of the
below?

A. DECIMAL(5,5)
B. DECIMAL(10,0)
C. DECIMAL(0,10)
D. DECIMAL(3,7)
Answer: B

QUESTION NO: 19
Which of the following statements will add two columns of INT type to the `country`
table?

A. ALTER TABLE country ADD rainfall INT ADD gdp INT


B. ALTER TABLE country ADD rainfall INT, gdp INT
C. ALTER TABLE country ADD rainfall INT, ADD gdp INT
D. ALTER TABLE country ADD rainfall INT gdp INT
E. You cannot add more than one column with a single ALTER TABLE statement
Answer: C

QUESTION NO: 20
The query below is attempting to CREATE a table based on the definition of the
`world` table, including any column attributes and indexes. What is missing? CREATE
TABLE t1 ______ world

A. FROM
B. USING
C. COPY
D. LIKE
Answer: D

QUESTION NO: 21
Which of the following will CREATE a table with exactly one multi-column index?

A. CREATE TABLE names ( id INT, name CHAR(20) NOT NULL, INDEX


name_id(id), INDEX name_id(name) )
B. CREATE TABLE names ( id INT, name CHAR(20) NOT NULL, INDEX(id),
INDEX(name) )
C. CREATE TABLE names ( id INT, name CHAR(20) NOT NULL, INDEX
name_id(id, name) )
D. CREATE TABLE names ( id INT, name CHAR(20) NOT NULL, INDEX(id,name)
)
E. An index cannot be made to extend across multiple columns.
Answer: C,D

QUESTION NO: 22
You have issued the statement: CREATE TABLE numbers (number INT NOT NULL)
ENGINE=MYISAM What is the result of issuing the following statement: INSERT INTO
numbers VALUES (NULL)

A. The table contains the value 0


B. The table contains the value NULL
C. The table is empty, no error message is returned
D. The table is empty and an error message is returned
Answer: D

QUESTION NO: 23
What is the benefit of creating an index on a table?

A. To quickly retrieve records from a table without scanning the entire table.
B. To constrain a column to a specific set of values.
C. To guarantee uniqueness for a column.
D. It can be used to establish a relationship to another table via a FOREIGN KEY.
Answer: A,C,D

QUESTION NO: 24
On a clean installation of the MySQL server (which contains only the databases test
and mysql), you select the test database as the default database. Which of the
following CREATE TABLE statements will succeed?

A. CREATE TABLE `my data` (i INT)


B. CREATE TABLE my data (i INT)
C. CREATE TABLE my_data (i INT)
D. CREATE TABLE my.data (i INT)
E. CREATE TABLE `my.data` (i INT)
Answer: A,C

QUESTION NO: 25
The table exams was created using the following statement: CREATE TABLE exams
( exam_id INTEGER UNSIGNED NOT NULL PRIMARY KEY, examinee_id INTEGER UNSIGNED
UNIQUE, score INTEGER UNSIGNED ) You need to make certain that examinee_id is
always defined and unique throughout the table. What changes (if any) should be
made to the table?

A. examinee_id should also be designated PRIMARY KEY.


B. NOT NULL should be added to examinee_id and removed from exam_id.
C. The PRIMARY KEY should be dropped and re-created as PRIMARY KEY (examinee_id,
exam_id).
D. NOT NULL should be added to examinee_id.
E. Nothing needs to be done; the needed checks are already in place for this table.
Answer: D

QUESTION NO: 26
Which of the following statements accurately describes the difference between HASH
and BTREE indexes used for MEMORY tables?

A. HASH indexes support rightmost prefixing of keys which makes them faster than
BTREE in many cases.
B. HASH indexes can be used by the optimizer to speed up ORDER BY operations by
minimizing use of the sort_buffer; BTREE indexes can not
be used this way.
C. HASH indexes are only used for equality comparisons (= or <=>), whereas BTREE
indexes can be used for range searches (> or <) as well.
D. HASH indexes are much faster than BTREE but can only be used for a single
column.
Answer: C

QUESTION NO: 27
You wish to create the table CountryLanguage which will contain the languages
spoken in each country across the world. All combinations of Country and Language
should be unique. Which of the following CREATE statements are the correct way of
specifying the table?

A. CREATE TABLE CountryLanguage ( Country CHAR(30) NOT NULL PRIMARY KEY, Language
CHAR(30) NOT NULL PRIMARY KEY )
B. CREATE TABLE CountryLanguage ( Country CHAR(30) NOT NULL, Language CHAR(30) NOT
NULL, PRIMARY KEY (Country,
Language) )
C. CREATE TABLE CountryLanguage ( Country CHAR(30) NOT NULL, Language CHAR(30) NOT
NULL, PRIMARY KEY (*) )
D. CREATE TABLE CountryLanguage ( Country CHAR(30) NOT NULL UNIQUE, Language
CHAR(30) NOT NULL UNIQUE )
E. CREATE TABLE CountryLanguage ( Country CHAR(30) NOT NULL, Language CHAR(30) NOT
NULL, UNIQUE (Country, Language)
)
F. CREATE TABLE CountryLanguage ( Country CHAR(30) NOT NULL, Language CHAR(30) NOT
NULL, UNIQUE (*) )
Answer: B,E

QUESTION NO: 28
Having the table Status defined with the following structure and data: mysql>
DESCRIBE Status; mysql> SELECT id, name FROM Status; Which of the following
statements are true?

A. The table has 4 rows.


B. The table has 1 row with column names and 3 rows with data.
C. There are 4 hidden rows.
D. The table has 3 columns, of which the column named comment is used internally by
MySQL.
E. There are 3 columns named id, name and comment, all of which are accessible to
the user.
Answer: A,E

QUESTION NO: 29
Consider the following table: mysql> DESC friends; 1 row in set (0.03 sec) Which of
the following statements can be used to change the name of the column name into
firstname?

A. ALTER TABLE friends CHANGE name firstname VARCHAR(20)


B. ALTER TABLE friends CHANGE name VARCHAR(20) firstname VARCHAR(20)
C. ALTER TABLE friends RENAME name TO firstname
Answer: A

QUESTION NO: 30
Which of the following MySQL client programs require a connection to a MySQL server
in order to work on database contents?

A. mysqlcheck
B. mysqldump
C. mysqlimport
D. myisamchk
Answer: A,B,C

QUESTION NO: 31
"The mysql command is used to start the MySQL database and open the prompt to
accept queries."

A. true
B. false
Answer: B

QUESTION NO: 32
Is the following statement true or false? If the MySQL server is started with
--sql-mode=IGNORE_SPACE, all function names are treated as reserved words

A. true
B. false
Answer: A

QUESTION NO: 33
Which of the following queries will return a value of NULL?

A. SELECT NULL = NULL


B. SELECT NULL IS NULL
C. SELECT NULL <=> NULL
D. SELECT 1 > NULL
Answer: A,D

QUESTION NO: 34
The table user has the following structure and contents. mysql> DESCRIBE user;
SELECT * FROM user; 'NULL' in the output is the NULL value, not the character
string 'NULL'. How many rows will the following query return? SELECT name,
telephone FROM user WHERE telephone=''

A. 0
B. 1
C. 2
D. 3
E. 4
Answer: B

QUESTION NO: 35
The friends table has the following data: mysql> select @@sql_mode; What will be
the result of the following statement: SELECT name FROM friends WHERE name LIKE
"P_t%"

A. The result depends on the type of the name column.


B. An empty set
C. Phillip, Patrick, Peter
D. Patrick, Peter
E. Pavel, Peter
Answer: D

QUESTION NO: 36
The table t has a column c with following contents: mysql> SELECT c FROM t; If c is
a CHAR column that has the case-insensitive latin1_swedish_ci collation what will
be the output of the following SQL statement? SELECT c, COUNT(*) from t GROUP BY c

A. B. Answer: B

QUESTION NO: 37
Which of the following statements are true?

A. Data in FLOAT columns is not subject to rounding errors.


B. Data in FLOAT columns is subject to rounding errors.
C. Data in DECIMAL columns is not subject to rounding errors.
D. Data in DECIMAL columns is subject to rounding errors.
E. Data in INTEGER columns is not subject to rounding errors.
F. Data in INTEGER columns is subject to rounding errors.
Answer: B,C,E

QUESTION NO: 38
Which sql-mode option is required for 'abc' || 'def' to be returned as the
concatenated string 'abcdef'?

A. --sql-mode=USE_CONCAT
B. --sql-mode=PIPES_AS_CONCAT
C. --sql-mode=NO_OR_CONCAT
D. --sql-mode=ANSI_CONCAT
Answer: B

QUESTION NO: 39
str is a multi-byte character string which contains five two-byte characters. What
will be the result of the following SQL statement? SELECT LENGTH(str),
CHAR_LENGTH(str)

A. 5, 5
B. NULL, NULL
C. 10, 5
D. 5, 10
Answer: C

QUESTION NO: 40
What does the following statement do? CREATE /*!32302 TEMPORARY */ TABLE t (a INT);

A. Create the non-temporary table t, as specified.


B. Create the table t as a TEMPORARY table only in MySQL Version 3.23.02, and as a
regular table in all other versions.
C. Create the table t as a TEMPORARY table only in MySQL Version 3.23.02 or newer,
and as a regular table in all other versions.
Answer: C

QUESTION NO: 41
What will be the result of the following SQL statement: SELECT IFNULL(1/0,'yes')

A. NULL
B. 1/0
C. 1
D. yes'
E. 0
Answer: D

QUESTION NO: 42
Consider the following: mysql> DESC item; mysql> SELECT * FROM item; What will be
the output of the following SELECT statement? SELECT SUM(price1) AS total1,
SUM(price2) AS total2 FROM item HAVING total1 = total2

A. B. C. The empty set


Answer: C

QUESTION NO: 43
What will be returned when the following statement is executed? SELECT INTERVAL(25,
12, 13, 32, 42)

A. NULL
B. 1
C. 2
D. 3
E. 13
F. 32
Answer: C

QUESTION NO: 44
Having connected to a server with the mysql client program, you have typed mysql>
UPDATE tbl SET str = 'sample and pressed Enter. Now the prompt looks like this: '>.
What does this mean?

A. The previous line is missing a statement terminator.


B. The previous line resulted in an error and needs to be corrected.
C. The previous line started a literal string which is still not complete.
D. The client is running in safe mode, and the statement has no WHERE clause.
Answer: C

QUESTION NO: 45
You would like to make a tab-delimited export for a result of a query using the
mysql client program invoked interactively. Which option do you need to pass to
mysql to achieve this?

A. --tab-delimited
B. --batch
C. --export
D. No option is necessary. Tab-delimited output is the default in interactive mode.
Answer: B

QUESTION NO: 46
When redirecting a file containing SQL statements into the mysql client program, an
error occurs as follows: ERROR 1007 (HY000) at line 1: Can't create database
'world'; database exists Which of the following parameters can be given to the
mysql client program to make it continue processing the file regardless of any
errors?

A. --force
B. --ignore-errors
C. --create-database-if-not-exists
D. --batch
Answer: A

QUESTION NO: 47
Having connected to a server with the mysql client program, you want to execute a
query. What statement terminator can you use to execute the query?

A. ;
B. \g
C. \c
D. \G
Answer: A,B,D

QUESTION NO: 48
In mysql, which of the following statements will provide a list of all accessible
help topics?

A. mysql> HELP ALL-TOPICS;


B. mysql> HELP ?;
C. mysql> HELP CONTENTS;
D. mysql> HELP CATEGORIES;
Answer: C

QUESTION NO: 49
When the following command is entered into the mysql client program, which of the
options below describes the parameter '/home/sakila/world.sql'? SOURCE
/home/sakila/world.sql
A. A file which is on a filesystem accessible by the computer where the MySQL
server is running and is readable by the server
B. A file which is on a filesystem accessible by the computer where the mysql
client program is running and is readable by the client
Answer: B

QUESTION NO: 50
Which of the following mysql startup options will you use to guard against long-
running SQL queries?

A. --safe-selects
B. --safe-updates
C. --safe-deletes
D. all of above
Answer: B

QUESTION NO: 51
When issuing a SELECT statement which of the following keywords is used to rename a
column?

A. ALIAS
B. AS
C. NAMED
D. RENAME
Answer: B

QUESTION NO: 52
Assuming a table Country exists with a column Name, which of the following are
valid uses of the LIMIT clause?

A. SELECT Name FROM Country LIMIT 100-50


B. SELECT Name FROM Country LIMIT 100,50
C. SELECT Name FROM Country LIMIT 35
D. SELECT Name FROM Country LIMIT @limitcount
E. SELECT Name FROM Country LIMIT RAND()
Answer: B,C

QUESTION NO: 53
What keyword is missing from the following query in order to ensure that all
results, including duplicates, are returned? SELECT time, action, user FROM
log20040101 UNION SELECT time, action, user FROM log20040102

A. NONDISTINCT
B. DUPLICATE
C. ALL
D. RELAXED
Answer: C

QUESTION NO: 54
The table Office is defined as follows: mysql> DESC Office; The following statement
is executed: mysql> SELECT DISTINCT city FROM Office; What would be the order of
the rows if the query is rewritten to: SELECT DISTINCT city FROM Office ORDER BY
city
A. Paris, Amsterdam, New York, Tokyo
B. Amsterdam, Paris, Tokyo, New York
C. Amsterdam, New York, Paris, Tokyo
D. New York, Paris, Tokyo, Amsterdam
Answer: A

QUESTION NO: 55
The friends table contains the following data: Assuming a suitable collation, how
can you retrieve the names in alphabetical order by last_name then first_name?

A. SELECT * FROM friends ORDER BY last_name, first_name DESC


B. SELECT * FROM friends ORDER BY first_name, last_name
C. SELECT last_name, first_name FROM friends ORDER BY last_name, first_name
D. SELECT * FROM friends
E. SELECT * FROM friends IN ORDER last_name, first_name
F. You can't order by more than one column at one time.
Answer: C

QUESTION NO: 56
Consider the item table with the following data: What will be the result of the
following SELECT? SELECT color, COUNT(*) FROM item GROUP BY color

A. B. C. Answer: C

QUESTION NO: 57
Assume that a table table1 contains the following data: mysql> SELECT * FROM
table1; 6 rows in set (0.00 sec) How many rows will be returned when the following
statement is executed? SELECT DISTINCT col1 FROM table1;

A. 6
B. 3
C. 4
Answer: C

QUESTION NO: 58
Consider the friends table is given by the following information: mysql> SELECT *
FROM friends; Which of the following SELECT statements are valid?

A. SELECT firstname FROM friends


B. SELECT lastname, age, 1 FROM friends
C. SELECT 'age'
D. SELECT 'age' WHERE 'age' > 30
Answer: A,B,C

QUESTION NO: 59
Which of the following comparisons is equivalent to: ( age >= 4 ) and ( age <= 8 )

A. age BETWEEN 4 and 8


B. age BETWEEN 3 and 9
C. age BETWEEN 5 and 7
D. age BETWEEN 4 and 7
Answer: A
QUESTION NO: 60
What would be the outcome when following statement is executed? SELECT Name FROM
City WHERE CountryCode = 'USA' OR WHERE CountryCode = 'JPN'

A. The city names from USA and JPN in one result set.
B. The city names from USA and JPN in two different result sets.
C. The city names from USA in the first column and the cities from JPN in the
second column.
D. An error message is issued.
Answer: D

QUESTION NO: 61
Consider the following table structure. mysql> DESCRIBE TEST; Why is it a bad idea
to use SELECT * instead of specifying the required columns by their name?

A. SELECT * may cause more data to be to be read from disk if your application only
needs some columns.
B. SELECT * causes more data to be sent over the network if your application only
needs some columns.
C. SELECT * prevents the use of indexes, so a full table scan is required for every
query.
D. SELECT * causes your application to depend on the columns present when you wrote
it, so your application could break if new columns are
added to the table structure
Answer: A,B,D

QUESTION NO: 62
Which of the following INSERT statements are syntactically correct?

A. INSERT INTO friends (id, name, lastname, age) VALUES (1, 'John', 'Doe', 22)
B. INSERT INTO friends VALUES (1, 'John', 'Doe', 22)
C. INSERT INTO friends ROWS (1, 'John', 'Doe', 22)
D. INSERT INTO friends SET id=1, name='John', lastname='Doe', age=22
Answer: A,B,D

QUESTION NO: 63
Having the table names defined as follows: mysql> DESC names; The table names
contains the following data: mysql> SELECT * FROM names; We then execute following
REPLACE statement: mysql> REPLACE INTO names VALUES (2, 'Jim'), (4, 'Tom'), (6,
'Matt'); What will be the output of SELECT * FROM names now?

A. B. Answer: B

QUESTION NO: 64
Complete the following sentence. An UPDATE statement issued without a WHERE clause
will...

A. ... result in an error.


B. ... update every row in the specified table(s).
Answer: B

QUESTION NO: 65
Consider the codes table is given by the following. DESC codes; mysql> SELECT *
FROM codes; +----+---------+ | id | code | +----+---------+ | 3 | Charlie |
+----+---------+ An INSERT statement as follows is issued. INSERT INTO codes VALUES
(1, 'Alpha'), (2, 'Beta'), (3, 'Charlie'), (4, 'Delta') Which of the following will
be the result of the following SELECT query given the codes table is of the type
specified? SELECT * FROM codes

A. MyIsam
B. InnoDBB.InnoDB
C. MyIsamC.MyIsamC.MyIsamC.MyIsamC.MyIsamC.MyIsamC.MyIsamC.MyIsam
D. InnoDBD.InnoDBD.InnoDBD.InnoDBD.InnoDBD.InnoDBD.InnoDB
E. MyIsamE.MyIsamE.MyIsamE.MyIsamE.MyIsamE.MyIsamE.MyIsamE.MyIsamE.MyIsam
F. InnoDBF.InnoDBF.InnoDBF.InnoDBF.InnoDBF.InnoDBF.InnoDBF.InnoDBF.InnoDB
Answer: B,C

QUESTION NO: 66
Which of the following privileges is required for using TRUNCATE?

A. DROP
B. TRUNCATE
C. DELETE
D. SUPER
Answer: C

QUESTION NO: 67
Which of the following are correct? A REPLACE statement may be used...

A. ... in place of a combination of DELETE and INSERT statements.


B. ... when the replacement of rows must be done in one atomic operation.
C. ... only on MyISAM tables.
D. ... only by the root user.
Answer: A,B

QUESTION NO: 68
Is the following statement true or false? "Connector/ODBC can only connect to a
MySQL server via TCP/IP; named pipes and sockets are not supported because they are
operating system specific."

A. true
B. false
Answer: B

QUESTION NO: 69
Where should a MySQL Connector be installed?

A. On the client-side host.


B. On the MySQL server host.
Answer: A

You might also like