Upwork MySQL Test 2016<<<>>>
72 Answered Test Questions:
1. Which of the following are true in case of Indexes for MYISAM Tables?Answers:
a. Indexes can have NULL values
a. BLOB and TEXT columns can be indexed
a. Indexes can have NULL values
a. BLOB and TEXT columns can be indexed
a. Indexes per table cannot be more than 16
a. Columns per index cannot be more than 16
2. Below is the table “messages,” please find proper query and result from the choices below.
a. Columns per index cannot be more than 16
2. Below is the table “messages,” please find proper query and result from the choices below.
Id Name Other_Columns
————————-
1 A A_data_1
2 A A_data_2
3 A A_data_3
4 B B_data_1
5 B B_data_2
6 C C_data_1
Answers:
a. select * from (select * from messages GROUP BY id DESC) AS x ORDER BY name Result: 3 A A_data_3 5 B B_data_2 6 C C_data_1
a. select * from messages where name =Desc Result: 1 A A_data_1 2 A A_data_2 3 A A_data_3
a. select * from messages group by name Result: 1 A A_data_1 4 B B_data_1 6 C C_data_1
a. Answer A and B
3. How can an user quickly rename a MySQL database for InnoDB?
Answers:
a. He cannot rename any MySQL database
a. By using: RENAME DATABASE db_old_name TO db_new_name
a. By using: RENAME DATABASE TO db_new_name
a. By creating the new empty database, then rename each table using: RENAME TABLE db_old_name.table_name TO db_new_name.table_name
4. Is it possible to insert several rows into a table with a single INSERT statement?
Answers:
a. No
a. Yes
5. Consider the following tables:
————————-
1 A A_data_1
2 A A_data_2
3 A A_data_3
4 B B_data_1
5 B B_data_2
6 C C_data_1
Answers:
a. select * from (select * from messages GROUP BY id DESC) AS x ORDER BY name Result: 3 A A_data_3 5 B B_data_2 6 C C_data_1
a. select * from messages where name =Desc Result: 1 A A_data_1 2 A A_data_2 3 A A_data_3
a. select * from messages group by name Result: 1 A A_data_1 4 B B_data_1 6 C C_data_1
a. Answer A and B
3. How can an user quickly rename a MySQL database for InnoDB?
Answers:
a. He cannot rename any MySQL database
a. By using: RENAME DATABASE db_old_name TO db_new_name
a. By using: RENAME DATABASE TO db_new_name
a. By creating the new empty database, then rename each table using: RENAME TABLE db_old_name.table_name TO db_new_name.table_name
4. Is it possible to insert several rows into a table with a single INSERT statement?
Answers:
a. No
a. Yes
5. Consider the following tables:
books
——
bookid
bookname
authorid
subjectid
popularityrating (the popularity of the book on a scale of 1 to 10)
language (such as French, English, German etc)
Subjects
———
subjectid
subject (such as History, Geography, Mathematics etc)
authors
——–
authorid
authorname
country
Which is the query to determine the Authors who have written at least 1 book with a popularity rating of less than 5?
Answers:
a. select authorname from authors where authorid in (select authorid from books where popularityrating<5)
a. select authorname from authors where authorid in (select authorid from books where popularityrating<=5)
a. select authorname from authors where authorid in (select bookid from books where popularityrating<5)
a. select authorname from authors where authorid in (select authorid from books where popularityrating in (0,5))
6. The Flush statement cannot be used for:
Answers:
a. Closing any open tables in the table cache
a. Closing open connections
a. Flushing the log file
a. Flushing the host cache
7. Consider the query:
Answers:
a. select authorname from authors where authorid in (select authorid from books where popularityrating<5)
a. select authorname from authors where authorid in (select authorid from books where popularityrating<=5)
a. select authorname from authors where authorid in (select bookid from books where popularityrating<5)
a. select authorname from authors where authorid in (select authorid from books where popularityrating in (0,5))
6. The Flush statement cannot be used for:
Answers:
a. Closing any open tables in the table cache
a. Closing open connections
a. Flushing the log file
a. Flushing the host cache
7. Consider the query:
SELECT name
FROM Students
WHERE name LIKE ‘_a%’;
Which names will be displayed?
Answers:
a. Names starting with “a”
a. Names containing “a” as the second lette
a. Names starting with “a” or “A”
a. Names containing “a” as any letter except the first
8. Which of the following is the best MySQL data type for currency values?
Answers:
a. SMALLINT
a. DECIMAL(19,4)
a. VARCHAR(32)
a. BIGINT
9. What are MySQL Spatial Data Types in the following list?
Answers:
a. GEOMETRY
a. CIRCLE
a. SQUARE
a. POINT
a. POLYGON
10. Examine the two SQL statements given below:
Answers:
a. Names starting with “a”
a. Names containing “a” as the second lette
a. Names starting with “a” or “A”
a. Names containing “a” as any letter except the first
8. Which of the following is the best MySQL data type for currency values?
Answers:
a. SMALLINT
a. DECIMAL(19,4)
a. VARCHAR(32)
a. BIGINT
9. What are MySQL Spatial Data Types in the following list?
Answers:
a. GEOMETRY
a. CIRCLE
a. SQUARE
a. POINT
a. POLYGON
10. Examine the two SQL statements given below:
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary DESC
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC
What is true about them?
Answers:
a. The two statements produce identical results
a. The second statement returns an error
a. There is no need to specify DESC because the results are sorted in descending order by default
a. None of the above statments is correct
11. Which of the following will raise MySQL’s version of an error?
Answers:
a. SIGNAL
a. RAISE
a. ERROR
a. None of these.
12. Which query will return values containing strings “Pizza”, “Burger”, or “Hotdog” in the database?
Answers:
a. SELECT * FROM fiberbox WHERE field REGEXP ‘Pizza|Burger|Hotdog’;
a. SELECT * FROM fiberbox WHERE field LIKE ‘%Pizza%’ OR field LIKE ‘%Burger%’ OR field LIKE ‘%Hotdog%’;
a. SELECT * FROM fiberbox WHERE field = ‘%Pizza%’ OR field = ‘%Burger%’ OR field = ‘%Hotdog%’;
a. SELECT * FROM fiberbox WHERE field = ‘?Pizza?’ OR field = ‘?Burger?’ OR field = ‘?Hotdog?’;
13. Which datatype is used to store binary data in MySQL?
Answers:
a. BLOB
a. BIGINT
a. INT
a. Both BLOB and BIGINT
14. Which of the following will reset the MySQL password for a particular user?
Answers:
a. UPDATE mysql.user SET Password=PASSWORD(‘password’) WHERE User=’username’;
a. UPDATE mysql.user SET Password=’password’ WHERE User=’username’;
a. UPDATE mysql.user SET Password=RESET(‘password’) WHERE User=’username’;
a. None of the above.
15. Which of the following is the best way to modify a table to allow null values?
Answers:
a. ALTER TABLE table_name MODIFY column_name varchar(255) null
a. ALTER TABLE table_name MODIFY column_name VARCHAR(255)
a. ALTER TABLE table_name CHANGE column_name column_name type DEFAULT NULL
a. ALTER table_name MODIFY column_name varchar(255) null
16. Which of the following will dump the whole MySQL database to a file?
Answers:
a. mysql -e “select * from myTable” -u myuser -pxxxxxxxxx mydatabase > mydumpfile.txt
a. mysql -e “select * from myTable” mydatabase > mydumpfile.txt
a. SELECT * from myTable FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘\n’
a. None of the above.
17. Which of the following statements is true regarding character sets in MySQL?
Answers:
a. The default character set of MySQL is UTF-8.
a. lang.cnf sets the default character set for MySQL databases.
a. SET CHARSET utf8 will set the character set of data to be imported to UTF-8.
a. None of these.
18. Which of the following is an alternative to groupwise maximum ranking (ex. ROW_NUMBER() in MS SQL)?
Answers:
a. Using subqueries
a. Using variables in a MySQL query
a. Using self-join
a. MySQL also supports ROW_NUMBER()
19. Consider the following tables:
Answers:
a. The two statements produce identical results
a. The second statement returns an error
a. There is no need to specify DESC because the results are sorted in descending order by default
a. None of the above statments is correct
11. Which of the following will raise MySQL’s version of an error?
Answers:
a. SIGNAL
a. RAISE
a. ERROR
a. None of these.
12. Which query will return values containing strings “Pizza”, “Burger”, or “Hotdog” in the database?
Answers:
a. SELECT * FROM fiberbox WHERE field REGEXP ‘Pizza|Burger|Hotdog’;
a. SELECT * FROM fiberbox WHERE field LIKE ‘%Pizza%’ OR field LIKE ‘%Burger%’ OR field LIKE ‘%Hotdog%’;
a. SELECT * FROM fiberbox WHERE field = ‘%Pizza%’ OR field = ‘%Burger%’ OR field = ‘%Hotdog%’;
a. SELECT * FROM fiberbox WHERE field = ‘?Pizza?’ OR field = ‘?Burger?’ OR field = ‘?Hotdog?’;
13. Which datatype is used to store binary data in MySQL?
Answers:
a. BLOB
a. BIGINT
a. INT
a. Both BLOB and BIGINT
14. Which of the following will reset the MySQL password for a particular user?
Answers:
a. UPDATE mysql.user SET Password=PASSWORD(‘password’) WHERE User=’username’;
a. UPDATE mysql.user SET Password=’password’ WHERE User=’username’;
a. UPDATE mysql.user SET Password=RESET(‘password’) WHERE User=’username’;
a. None of the above.
15. Which of the following is the best way to modify a table to allow null values?
Answers:
a. ALTER TABLE table_name MODIFY column_name varchar(255) null
a. ALTER TABLE table_name MODIFY column_name VARCHAR(255)
a. ALTER TABLE table_name CHANGE column_name column_name type DEFAULT NULL
a. ALTER table_name MODIFY column_name varchar(255) null
16. Which of the following will dump the whole MySQL database to a file?
Answers:
a. mysql -e “select * from myTable” -u myuser -pxxxxxxxxx mydatabase > mydumpfile.txt
a. mysql -e “select * from myTable” mydatabase > mydumpfile.txt
a. SELECT * from myTable FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘\n’
a. None of the above.
17. Which of the following statements is true regarding character sets in MySQL?
Answers:
a. The default character set of MySQL is UTF-8.
a. lang.cnf sets the default character set for MySQL databases.
a. SET CHARSET utf8 will set the character set of data to be imported to UTF-8.
a. None of these.
18. Which of the following is an alternative to groupwise maximum ranking (ex. ROW_NUMBER() in MS SQL)?
Answers:
a. Using subqueries
a. Using variables in a MySQL query
a. Using self-join
a. MySQL also supports ROW_NUMBER()
19. Consider the following tables:
Books
——
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)
——
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)
Subjects
———
SubjectId
Subject (such as History, Geography, Mathematics etc)
———
SubjectId
Subject (such as History, Geography, Mathematics etc)
Authors
——–
AuthorId
AuthorName
Country
——–
AuthorId
AuthorName
Country
Which query will determine how many books have a popularity rating of more than 7 on each subject?
Answers:
a. select subject,count(*) as Books from books,subjects where books.popularityrating > 7
a. select subject,count(*) as Books from books,subjects where books.authorid=subjects.authorid and books.popularityrating > 7 group by subjects.subject
a. select subject,count(*) as Books from books,subjects where books.subjectid=subjects.subjectid and books.popularityrating = 7 group by subjects.subject
a. select subject,count(*) as Books from books,subjects where books.subjectid=subjects.subjectid and books.popularityrating > 7 group by subjects.subject
20. Which of the following statements are true about SQL injection attacks?
Answers:
a. Wrapping all variables containing user input by a call to mysql_real_escape_string() makes the code immune to SQL injections.
a. Parametrized queries do not make code less vulnearable to SQL injections.
a. SQL injections are not possible, if only emulated prepared statements are used.
a. Usage of later versions of MySQL, validation, and explicit setting of the charset of user input are valid measures to decrease vulnerability to SQL injections.
21. Which of the following is an alternative to Subquery Factoring (ex. the ‘WITH’ clause in MS SQL Server)?
Answers:
a. The ‘IN’ clause
a. Using temporary tables and inline views
a. The ‘INNER JOIN’ clause
a. Using subqueries
22. Suppose a table has the following records:
Answers:
a. select subject,count(*) as Books from books,subjects where books.popularityrating > 7
a. select subject,count(*) as Books from books,subjects where books.authorid=subjects.authorid and books.popularityrating > 7 group by subjects.subject
a. select subject,count(*) as Books from books,subjects where books.subjectid=subjects.subjectid and books.popularityrating = 7 group by subjects.subject
a. select subject,count(*) as Books from books,subjects where books.subjectid=subjects.subjectid and books.popularityrating > 7 group by subjects.subject
20. Which of the following statements are true about SQL injection attacks?
Answers:
a. Wrapping all variables containing user input by a call to mysql_real_escape_string() makes the code immune to SQL injections.
a. Parametrized queries do not make code less vulnearable to SQL injections.
a. SQL injections are not possible, if only emulated prepared statements are used.
a. Usage of later versions of MySQL, validation, and explicit setting of the charset of user input are valid measures to decrease vulnerability to SQL injections.
21. Which of the following is an alternative to Subquery Factoring (ex. the ‘WITH’ clause in MS SQL Server)?
Answers:
a. The ‘IN’ clause
a. Using temporary tables and inline views
a. The ‘INNER JOIN’ clause
a. Using subqueries
22. Suppose a table has the following records:
+————–+————-+—————-+
| Item | Price | Brand |
+————–+————-+—————-+
| Watch | 100 | abc |
| Watch | 200 | xyz |
| Glasses | 300 | bcd |
| Watch | 500 | def |
| Glasses | 600 | fgh |
+————–+————-+—————-+
| Item | Price | Brand |
+————–+————-+—————-+
| Watch | 100 | abc |
| Watch | 200 | xyz |
| Glasses | 300 | bcd |
| Watch | 500 | def |
| Glasses | 600 | fgh |
+————–+————-+—————-+
Which of the following will select the highest-priced record per item?
Answers:
a. select item, brand, price from items where max(price) order by item
a. select * from items where price = max group by item
a. select item, brand, max(price) from items group by item
a. select * from items where price > 200 order by item
23. Which of the following will restore a MySQL DB from a .dump file?
Answers:
a. mysql -u -p < db_backup.dump
a. mysql -u -p < db_backup.dump
a. mysql -u -p < db_backup.dump
a. mysql -u -p > db_backup.dump
24. Which of the following will show when a table in a MySQL database was last updated?
Answers:
a. Using the following query: SELECT UPDATE_TIME FROM information_schema.tables WHERE TABLE_SCHEMA = ‘database_name’ AND TABLE_NAME = ‘table_name’
a. Creating an on-update trigger to write timestamp in a custom table, then querying the custom table
a. Getting the “last modified” timestamp of the corresponding database file in the file system
a. None of these.
25. Which of the following results in 0 (false)?
Answers:
a. “EXPERTRATING” LIKE “EXP%”
a. “EXPERTRATING” LIKE “Exp%”
a. BINARY “EXPERTRATING” LIKE “EXP%”
a. BINARY “EXPERTRATING” LIKE “Exp%”
a. All will result in 1 (true)
26. Which of the following relational database management systems is simple to embed in a larger program?
Answers:
a. MySQL
a. SQLite
a. Both
a. None
27. What is true about the ENUM data type?
Answers:
a. An enum value may be a user variable
a. An enum may contain number enclosed in quotes
a. An enum cannot contain an empty string
a. An enum value may be NULL
a. None of the above is true
28. What will happen if two tables in a database are named rating and RATING?
Answers:
a. This is not possible as table names are case in-sensitive (rating and RATING are treated as same name)
a. This is possible as table names are case sensitive (rating and RATING are treated as different names)
a. This is possible on UNIX/LINUX and not on Windows platform
a. This is possible on Windows and not on UNIX/LINUX platforms
a. This depends on lower_case_table_names system variable
29. How can a InnoDB database be backed up without locking the tables?
Answers:
a. mysqldump –single-transaction db_name
a. mysqldump –force db_name
a. mysqldump –quick db_name
a. mysqldump –no-tablespaces db_name
30. What does the term “overhead” mean in MySQL?
Answers:
a. Temporary diskspace that the database uses to run some of the queries
a. The size of a table
a. A tablespace name
a. None of the above
31. Consider the following select statement and its output:
Answers:
a. select item, brand, price from items where max(price) order by item
a. select * from items where price = max group by item
a. select item, brand, max(price) from items group by item
a. select * from items where price > 200 order by item
23. Which of the following will restore a MySQL DB from a .dump file?
Answers:
a. mysql -u -p < db_backup.dump
a. mysql -u -p < db_backup.dump
a. mysql -u -p < db_backup.dump
a. mysql -u -p > db_backup.dump
24. Which of the following will show when a table in a MySQL database was last updated?
Answers:
a. Using the following query: SELECT UPDATE_TIME FROM information_schema.tables WHERE TABLE_SCHEMA = ‘database_name’ AND TABLE_NAME = ‘table_name’
a. Creating an on-update trigger to write timestamp in a custom table, then querying the custom table
a. Getting the “last modified” timestamp of the corresponding database file in the file system
a. None of these.
25. Which of the following results in 0 (false)?
Answers:
a. “EXPERTRATING” LIKE “EXP%”
a. “EXPERTRATING” LIKE “Exp%”
a. BINARY “EXPERTRATING” LIKE “EXP%”
a. BINARY “EXPERTRATING” LIKE “Exp%”
a. All will result in 1 (true)
26. Which of the following relational database management systems is simple to embed in a larger program?
Answers:
a. MySQL
a. SQLite
a. Both
a. None
27. What is true about the ENUM data type?
Answers:
a. An enum value may be a user variable
a. An enum may contain number enclosed in quotes
a. An enum cannot contain an empty string
a. An enum value may be NULL
a. None of the above is true
28. What will happen if two tables in a database are named rating and RATING?
Answers:
a. This is not possible as table names are case in-sensitive (rating and RATING are treated as same name)
a. This is possible as table names are case sensitive (rating and RATING are treated as different names)
a. This is possible on UNIX/LINUX and not on Windows platform
a. This is possible on Windows and not on UNIX/LINUX platforms
a. This depends on lower_case_table_names system variable
29. How can a InnoDB database be backed up without locking the tables?
Answers:
a. mysqldump –single-transaction db_name
a. mysqldump –force db_name
a. mysqldump –quick db_name
a. mysqldump –no-tablespaces db_name
30. What does the term “overhead” mean in MySQL?
Answers:
a. Temporary diskspace that the database uses to run some of the queries
a. The size of a table
a. A tablespace name
a. None of the above
31. Consider the following select statement and its output:
SELECT * FROM table1 ORDER BY column1;
Column1
——–
1
2
2
2
2
2
3
Given the above output, which one of the following commands deletes 3 of the 5 rows where column1 equals 2?
Answers:
a. DELETE FIRST 4 FROM table1 WHERE column1=2
a. DELETE 4 FROM table1 WHERE column1=2
a. DELETE WHERE column1=2 LIMIT 4
a. DELETE FROM table1 WHERE column1=2 LIMIT 3
a. DELETE FROM table1 WHERE column1=2 LEAVING 1
32. Consider the following queries:
Answers:
a. DELETE FIRST 4 FROM table1 WHERE column1=2
a. DELETE 4 FROM table1 WHERE column1=2
a. DELETE WHERE column1=2 LIMIT 4
a. DELETE FROM table1 WHERE column1=2 LIMIT 3
a. DELETE FROM table1 WHERE column1=2 LEAVING 1
32. Consider the following queries:
create table foo (id int primary key auto_increment, name int);
create table foo2 (id int auto_increment primary key, foo_id int references foo(id) on delete cascade);
create table foo2 (id int auto_increment primary key, foo_id int references foo(id) on delete cascade);
Which of the following statements is true?
Answers:
a. Two tables are created
a. If a row in table foo2, with a foo_id of 2 is deleted, then the row with id = 2 in table foo is automatically deleted
a. Those queries are invalid
a. If a row with id = 2 in table foo is deleted, all rows with foo_id = 2 in table foo2 are deleted
33. What is NDB?
Answers:
a. An in-memory storage engine offering high-availability and data-persistence features
a. A filesystem
a. An SQL superset
a. MySQL scripting language
a. None of the above
34. Which of the following statements are true?
Answers:
a. Names of databases, tables and columns can be up to 64 characters in length
a. Alias names can be up to 255 characters in length
a. Names of databases, tables and columns can be up to 256 characters in length
a. Alias names can be up to 64 characters in length
35. Which of the following statements is used to change the structure of a table once it has been created?
Answers:
a. CHANGE TABLE
a. MODIFY TABLE
a. ALTER TABLE
a. UPDATE TABLE
36. What does DETERMINISTIC mean in the creation of a function?
Answers:
a. The function returns no value
a. The function always returns the same value for the same input
a. The function returns the input value
a. None of the above
37. Which of the following statements grants permission to Peter with password Software?
Answers:
a. GRANT ALL ON testdb.* TO peter PASSWORD ‘Software’
a. GRANT ALL ON testdb.* TO peter IDENTIFIED by ‘Software’
a. GRANT ALL OF testdb.* TO peter PASSWORD ‘Software’
a. GRANT ALL OF testdb.* TO peter IDENTIFIED by ‘Software’
38. What will happen if you query the emp table as shown below:
Answers:
a. Two tables are created
a. If a row in table foo2, with a foo_id of 2 is deleted, then the row with id = 2 in table foo is automatically deleted
a. Those queries are invalid
a. If a row with id = 2 in table foo is deleted, all rows with foo_id = 2 in table foo2 are deleted
33. What is NDB?
Answers:
a. An in-memory storage engine offering high-availability and data-persistence features
a. A filesystem
a. An SQL superset
a. MySQL scripting language
a. None of the above
34. Which of the following statements are true?
Answers:
a. Names of databases, tables and columns can be up to 64 characters in length
a. Alias names can be up to 255 characters in length
a. Names of databases, tables and columns can be up to 256 characters in length
a. Alias names can be up to 64 characters in length
35. Which of the following statements is used to change the structure of a table once it has been created?
Answers:
a. CHANGE TABLE
a. MODIFY TABLE
a. ALTER TABLE
a. UPDATE TABLE
36. What does DETERMINISTIC mean in the creation of a function?
Answers:
a. The function returns no value
a. The function always returns the same value for the same input
a. The function returns the input value
a. None of the above
37. Which of the following statements grants permission to Peter with password Software?
Answers:
a. GRANT ALL ON testdb.* TO peter PASSWORD ‘Software’
a. GRANT ALL ON testdb.* TO peter IDENTIFIED by ‘Software’
a. GRANT ALL OF testdb.* TO peter PASSWORD ‘Software’
a. GRANT ALL OF testdb.* TO peter IDENTIFIED by ‘Software’
38. What will happen if you query the emp table as shown below:
select empno, DISTINCT ename, Salary from emp;
Answers:
a. EMPNO, unique value of ENAME and then SALARY are displayed
a. EMPNO, unique value ENAME and unique value of SALARY are displayed
a. DISTINCT is not a valid keyword in SQL
a. No values will be displayed because the statement will return an error
39. Which of the following is the best way to disable caching for a query?
Answers:
a. Add the /*!no_query_cache*/ comment to the query.
a. Flush the whole cache with the command: FLUSH QUERY CACHE
a. Reset the query cache with the command: RESET QUERY CACHE
a. Use the SQL_NO_CACHE option in the query.
40. What is the maximum size of a row in a MyISAM table?
Answers:
a. No limit
a. OS specific
a. 65,534
a. 2’147’483’648
a. 128
41. Can you run multiple MySQL servers on a single machine?
Answers:
a. No
a. Yes
42. Which of the following formats does the date field accept by default?
Answers:
a. DD-MM-YYYY
a. YYYY-DD-MM
a. YYYY-MM-DD
a. MM-DD-YY
a. MMDDYYYY
43. State whether true or false:
Answers:
a. EMPNO, unique value of ENAME and then SALARY are displayed
a. EMPNO, unique value ENAME and unique value of SALARY are displayed
a. DISTINCT is not a valid keyword in SQL
a. No values will be displayed because the statement will return an error
39. Which of the following is the best way to disable caching for a query?
Answers:
a. Add the /*!no_query_cache*/ comment to the query.
a. Flush the whole cache with the command: FLUSH QUERY CACHE
a. Reset the query cache with the command: RESET QUERY CACHE
a. Use the SQL_NO_CACHE option in the query.
40. What is the maximum size of a row in a MyISAM table?
Answers:
a. No limit
a. OS specific
a. 65,534
a. 2’147’483’648
a. 128
41. Can you run multiple MySQL servers on a single machine?
Answers:
a. No
a. Yes
42. Which of the following formats does the date field accept by default?
Answers:
a. DD-MM-YYYY
a. YYYY-DD-MM
a. YYYY-MM-DD
a. MM-DD-YY
a. MMDDYYYY
43. State whether true or false:
In the ‘where clause’ of a select statement, the AND operator displays a row if any of the conditions listed are true. The OR operator displays a row if all of the conditions listed are true.
Answers:
a. True
a. False
44. What is the name of the utility used to extract NDB configuration information?
Answers:
a. ndb_config
a. cluster_config
a. ndb –config
a. configNd
a. None of the above
45. Which one of the following must be specified in every DELETE statement?
Answers:
a. Table Name
a. Database name
a. LIMIT clause
a. WHERE clause
46. Which of the following are not Numeric column types?
Answers:
a. BIGINT
a. LARGEINT
a. SMALLINT
a. DOUBLE
a. DECIMAL
47. Which of the following statements is true regarding multi-table querying in MySQL?
Answers:
a. JOIN queries are faster than WHERE queries.
a. WHERE queries are faster than JOIN queries.
a. INNER queries are faster than JOIN queries.
a. WHERE & INNER offer the same performance in terms of speed.
48. What is wrong with the following statement?
Answers:
a. True
a. False
44. What is the name of the utility used to extract NDB configuration information?
Answers:
a. ndb_config
a. cluster_config
a. ndb –config
a. configNd
a. None of the above
45. Which one of the following must be specified in every DELETE statement?
Answers:
a. Table Name
a. Database name
a. LIMIT clause
a. WHERE clause
46. Which of the following are not Numeric column types?
Answers:
a. BIGINT
a. LARGEINT
a. SMALLINT
a. DOUBLE
a. DECIMAL
47. Which of the following statements is true regarding multi-table querying in MySQL?
Answers:
a. JOIN queries are faster than WHERE queries.
a. WHERE queries are faster than JOIN queries.
a. INNER queries are faster than JOIN queries.
a. WHERE & INNER offer the same performance in terms of speed.
48. What is wrong with the following statement?
create table foo (id int auto_increment, name int);
Answers:
a. Nothing
a. The id column cannot be auto incremented because it has not been defined as a primary key
a. It is not spelled correctly. It should be: CREATE TABLE foo (id int AUTO_INCREMENT, name int);
49. Consider the following table definition:
Answers:
a. Nothing
a. The id column cannot be auto incremented because it has not been defined as a primary key
a. It is not spelled correctly. It should be: CREATE TABLE foo (id int AUTO_INCREMENT, name int);
49. Consider the following table definition:
CREATE TABLE table1 (
column1 INT,
column2 INT,
column3 INT,
column4 INT
)
column1 INT,
column2 INT,
column3 INT,
column4 INT
)
Which one of the following is the correct syntax for adding the column, “column2a” after column2, to the table shown above?
Answers:
a. ALTER TABLE table1 ADD column2a INT AFTER column2
a. MODIFY TABLE table1 ADD column2a AFTER column2
a. INSERT INTO table1 column2a AS INT AFTER column2
a. ALTER TABLE table1 INSERT column2a INT AFTER column2
a. CHANGE TABLE table1 INSERT column2a BEFORE column3
a. Columns are always added after the last column
50. Examine the data in the employees table given below:
Answers:
a. ALTER TABLE table1 ADD column2a INT AFTER column2
a. MODIFY TABLE table1 ADD column2a AFTER column2
a. INSERT INTO table1 column2a AS INT AFTER column2
a. ALTER TABLE table1 INSERT column2a INT AFTER column2
a. CHANGE TABLE table1 INSERT column2a BEFORE column3
a. Columns are always added after the last column
50. Examine the data in the employees table given below:
last_name department_id salary
ALLEN 10 3000
MILLER 20 1500
King 20 2200
Davis 30 5000
Which of the following Subqueries will execute well?
Answers:
a. SELECT * FROM employees where salary > (SELECT MIN(salary) FROM employees GROUP BY department_id);
a. SELECT * FROM employees WHERE salary = (SELECT AVG(salary) FROM employees GROUP BY department_id);
a. SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
a. SELECT department_id FROM employees WHERE SALARY > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);
a. SELECT department_id FROM employees WHERE salary > ALL (SELECT AVG(salary) FROM employees GROUP BY AVG(SALARY));
51. What privilege do you need to create a function?
Answers:
a. UPDATE
a. CREATE ROUTINE
a. SELECT
a. CREATE FUNCTION
a. No specific privilege
52. What is wrong with the following query:
Answers:
a. SELECT * FROM employees where salary > (SELECT MIN(salary) FROM employees GROUP BY department_id);
a. SELECT * FROM employees WHERE salary = (SELECT AVG(salary) FROM employees GROUP BY department_id);
a. SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
a. SELECT department_id FROM employees WHERE SALARY > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);
a. SELECT department_id FROM employees WHERE salary > ALL (SELECT AVG(salary) FROM employees GROUP BY AVG(SALARY));
51. What privilege do you need to create a function?
Answers:
a. UPDATE
a. CREATE ROUTINE
a. SELECT
a. CREATE FUNCTION
a. No specific privilege
52. What is wrong with the following query:
select * from Orders where OrderID = (select OrderID from OrderItems where ItemQty > 50)
Answers:
a. In the sub query, ‘*’ should be used instead of ‘OrderID’
a. The sub query can return more than one row, so, ‘=’ should be replaced with ‘in’
a. The sub query should not be in parenthesis
a. None of the above
53. Which of the following is a correct way to show the last queries executed on MySQL?
Answers:
a. First execute SET GLOBAL log_output = ‘TABLE’; Then execute SET GLOBAL general_log = ‘ON’; The last queries executed are saved in the table mysql.general_log
a. Edit the MySQL config file (mysql.con) and add the following line log = /var/log/mysql/mysql.log
a. Execute VIEW .mysql_history
a. Restart MySQL using the following line tail -f /var/log/mysql/mysql.log
54. Choose the appropriate query for the Products table where data should be displayed primarily in ascending order of the ProductGroup column. Secondary sorting should be in descending order of the CurrentStock column.
Answers:
a. Select * from Products order by CurrentStock,ProductGroup
a. Select * from Products order by CurrentStock DESC,ProductGroup
a. Select * from Products order by ProductGroup,CurrentStock
a. Select * from Products order by ProductGroup,CurrentStock DESC
a. None of the above
55. What is the correct SQL syntax for returning all the columns from a table named “Persons” sorted REVERSE alphabetically by “FirstName”?
Answers:
a. SELECT * FROM Persons WHERE FirstName ORDER BY FirstName DESC
a. SELECT * FROM Persons SORT REVERSE ‘FirstName’
a. SELECT * FROM Persons ORDER BY -‘FirstName’
a. SELECT * FROM Persons ORDER BY FirstName DESC
56. You want to display the titles of books that meet the following criteria:
Answers:
a. In the sub query, ‘*’ should be used instead of ‘OrderID’
a. The sub query can return more than one row, so, ‘=’ should be replaced with ‘in’
a. The sub query should not be in parenthesis
a. None of the above
53. Which of the following is a correct way to show the last queries executed on MySQL?
Answers:
a. First execute SET GLOBAL log_output = ‘TABLE’; Then execute SET GLOBAL general_log = ‘ON’; The last queries executed are saved in the table mysql.general_log
a. Edit the MySQL config file (mysql.con) and add the following line log = /var/log/mysql/mysql.log
a. Execute VIEW .mysql_history
a. Restart MySQL using the following line tail -f /var/log/mysql/mysql.log
54. Choose the appropriate query for the Products table where data should be displayed primarily in ascending order of the ProductGroup column. Secondary sorting should be in descending order of the CurrentStock column.
Answers:
a. Select * from Products order by CurrentStock,ProductGroup
a. Select * from Products order by CurrentStock DESC,ProductGroup
a. Select * from Products order by ProductGroup,CurrentStock
a. Select * from Products order by ProductGroup,CurrentStock DESC
a. None of the above
55. What is the correct SQL syntax for returning all the columns from a table named “Persons” sorted REVERSE alphabetically by “FirstName”?
Answers:
a. SELECT * FROM Persons WHERE FirstName ORDER BY FirstName DESC
a. SELECT * FROM Persons SORT REVERSE ‘FirstName’
a. SELECT * FROM Persons ORDER BY -‘FirstName’
a. SELECT * FROM Persons ORDER BY FirstName DESC
56. You want to display the titles of books that meet the following criteria:
1. Purchased before November 11, 2002
2. Price is less than $500 or greater than $900
2. Price is less than $500 or greater than $900
You want to sort the result by the date of purchase, starting with the most recently bought book.
Which of the following statements should you use?
Answers:
a. SELECT book_title FROM books WHERE price between 500 and 900 AND purchase_date < ‘2002-11-11’ ORDER BY purchase_date;
a. SELECT book_title FROM books WHERE price IN (500, 900) AND purchase_date< ‘2002-11-11’ ORDER BY purchase date ASC;
a. SELECT book_title FROM books WHERE price < 500 OR>900 AND purchase_date DESC;
a. SELECT book_title FROM books WHERE (price < 500 OR price > 900) AND purchase_date < ‘2002-11-11’ ORDER BY purchase_date DESC;
57. State whether true or false:
Which of the following statements should you use?
Answers:
a. SELECT book_title FROM books WHERE price between 500 and 900 AND purchase_date < ‘2002-11-11’ ORDER BY purchase_date;
a. SELECT book_title FROM books WHERE price IN (500, 900) AND purchase_date< ‘2002-11-11’ ORDER BY purchase date ASC;
a. SELECT book_title FROM books WHERE price < 500 OR>900 AND purchase_date DESC;
a. SELECT book_title FROM books WHERE (price < 500 OR price > 900) AND purchase_date < ‘2002-11-11’ ORDER BY purchase_date DESC;
57. State whether true or false:
Transactions and commit/rollback are supported by MySQL using the MyISAM engine
Answers:
a. True
a. False
58. Consider the following table structure of students:
Answers:
a. True
a. False
58. Consider the following table structure of students:
rollno int
name varchar(20)
course varchar(20)
What will be the query to display the courses in which the number of students enrolled is more than 5?
Answers:
a. Select course from students where count(course) > 5;
a. Select course from students where count(*) > 5 group by course;
a. Select course from students group by course;
a. Select course from students group by course having count(*) > 5;
a. Select course from students group by course where count(*) > 5;
a. Select course from students where count(group(course)) > 5;
a. Select count(course) > 5 from students;
a. None of the above
59. MySQL supports 5 different int types. Which one takes 3 bytes?
Answers:
a. TINYINT
a. MEDIUMINT
a. SMALLINT
a. INT
a. BIGINT
60. Which of the following is the correct way to determine duplicate values?
Answers:
a. SELECT column_duplicated, sum(*) amount FROM table_name WHERE amount > 1 GROUP BY column_duplicated
a. SELECT column_duplicated, COUNT(*) amount FROM table_name WHERE amount > 1 GROUP BY column_duplicated
a. SELECT column_duplicated, sum(*) amount FROM table_name GROUP BY column_duplicated HAVING amount > 1
a. SELECT column_duplicated, COUNT(*) amount FROM table_name GROUP BY column_duplicated HAVING amount > 1
61. Examine the query:-
Answers:
a. Select course from students where count(course) > 5;
a. Select course from students where count(*) > 5 group by course;
a. Select course from students group by course;
a. Select course from students group by course having count(*) > 5;
a. Select course from students group by course where count(*) > 5;
a. Select course from students where count(group(course)) > 5;
a. Select count(course) > 5 from students;
a. None of the above
59. MySQL supports 5 different int types. Which one takes 3 bytes?
Answers:
a. TINYINT
a. MEDIUMINT
a. SMALLINT
a. INT
a. BIGINT
60. Which of the following is the correct way to determine duplicate values?
Answers:
a. SELECT column_duplicated, sum(*) amount FROM table_name WHERE amount > 1 GROUP BY column_duplicated
a. SELECT column_duplicated, COUNT(*) amount FROM table_name WHERE amount > 1 GROUP BY column_duplicated
a. SELECT column_duplicated, sum(*) amount FROM table_name GROUP BY column_duplicated HAVING amount > 1
a. SELECT column_duplicated, COUNT(*) amount FROM table_name GROUP BY column_duplicated HAVING amount > 1
61. Examine the query:-
select (2/2/4) from tab1;
where tab1 is a table with one row. This would give a result of:
Answers:
a. 4
a. 2
a. 1
a. .5
a. .25
a. 8
a. 24
62. Which of the following commands will list the tables of the current database?
Answers:
a. SHOW TABLES
a. DESCRIBE TABLES
a. SHOW ALL TABLES
a. LIST TABLES
63. Which of the following is not a MySQL statement?
Answers:
a. ENUMERATE
a. EXPLAIN
a. KILL
a. LOAD DATA
a. SET
64. When running the following SELECT query:
Answers:
a. 4
a. 2
a. 1
a. .5
a. .25
a. 8
a. 24
62. Which of the following commands will list the tables of the current database?
Answers:
a. SHOW TABLES
a. DESCRIBE TABLES
a. SHOW ALL TABLES
a. LIST TABLES
63. Which of the following is not a MySQL statement?
Answers:
a. ENUMERATE
a. EXPLAIN
a. KILL
a. LOAD DATA
a. SET
64. When running the following SELECT query:
SELECT ID FROM (
SELECT ID, name FROM (
SELECT *
FROM employee
)
);
SELECT ID, name FROM (
SELECT *
FROM employee
)
);
The error message ‘Every derived table must have its own alias’ appears.
Which of the following is the best solution for this error?
Answers:
a. SELECT ID FROM ( SELECT ID AS SECOND_ID, name FROM ( SELECT * FROM employee ) );
a. SELECT ID FROM ( SELECT ID, name AS NAME FROM ( SELECT * FROM employee ) );
a. SELECT ID FROM ( SELECT ID, name FROM ( SELECT * FROM employee ) AS T ) AS T;
Which of the following is the best solution for this error?
Answers:
a. SELECT ID FROM ( SELECT ID AS SECOND_ID, name FROM ( SELECT * FROM employee ) );
a. SELECT ID FROM ( SELECT ID, name AS NAME FROM ( SELECT * FROM employee ) );
a. SELECT ID FROM ( SELECT ID, name FROM ( SELECT * FROM employee ) AS T ) AS T;
a. SELECT ID AS FIRST_ID FROM ( SELECT ID, name FROM ( SELECT * FROM employee ) );
65. Which of the following is not a Table Storage specifier in MySQL?
Answers:
a. InnoDB
a. MYISAM
a. BLACKHOLE
a. STACK
66. The REPLACE statement is:
Answers:
a. Same as the INSERT statement
a. Like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted
a. There is no such statement as REPLACE
67. If you try to perform an arithmetic operation on a column containing NULL values, the output will be:
Answers:
a. NULL
a. An error will be generated
a. Cannot be determined
68. Which of the following is the best way to insert a row, and to update an existing row, using a MySQL query?
Answers:
a. Use MERGE statement
a. Use INSERT … ON DUPLICATE KEY UPDATE statement
a. Use ADD UNIQUE statement
a. Use REPLACE statement
69. How will you change “Hansen” into “Nilsen” in the LastName column in the Persons Table?
Answers:
a. UPDATE Persons SET LastName = ‘Nilsen’ WHERE LastName = ‘Hansen’
a. UPDATE Persons SET LastName = ‘Hansen’ INTO LastName = ‘Nilsen’
a. SAVE Persons SET LastName = ‘Nilsen’ WHERE LastName = ‘Hansen’
a. SAVE Persons SET LastName = ‘Hansen’ INTO LastName = ‘Nilsen’
70. Which one of the following correctly selects rows from the table myTable that have NULL in column column1?
Answers:
a. SELECT * FROM myTable WHERE column1 IS NULL
a. SELECT * FROM myTable WHERE column1 = NULL
a. SELECT * FROM myTable WHERE column1 EQUALS NULL
a. SELECT * FROM myTable WHERE column1 NOT NULL
a. SELECT * FROM myTable WHERE column1 CONTAINS NULL
71. Is the FROM clause necessary in every SELECT statement?
Answers:
a. Yes
a. No
72. Which command will make a backup on the whole database except the tables sessions and log?
Answers:
a. mysqldump db_name sessions log > backup.sql
a. mysqldump db_name | grep -vv -E “sessions|log” > backup.sql
a. mysqldump db_name –ignore-table db_name.sessions db_name.log > backup.sql
a. mysqldump db_name –except-table=db_name.sessions –except-table=db_name.log > backup.sql
65. Which of the following is not a Table Storage specifier in MySQL?
Answers:
a. InnoDB
a. MYISAM
a. BLACKHOLE
a. STACK
66. The REPLACE statement is:
Answers:
a. Same as the INSERT statement
a. Like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted
a. There is no such statement as REPLACE
67. If you try to perform an arithmetic operation on a column containing NULL values, the output will be:
Answers:
a. NULL
a. An error will be generated
a. Cannot be determined
68. Which of the following is the best way to insert a row, and to update an existing row, using a MySQL query?
Answers:
a. Use MERGE statement
a. Use INSERT … ON DUPLICATE KEY UPDATE statement
a. Use ADD UNIQUE statement
a. Use REPLACE statement
69. How will you change “Hansen” into “Nilsen” in the LastName column in the Persons Table?
Answers:
a. UPDATE Persons SET LastName = ‘Nilsen’ WHERE LastName = ‘Hansen’
a. UPDATE Persons SET LastName = ‘Hansen’ INTO LastName = ‘Nilsen’
a. SAVE Persons SET LastName = ‘Nilsen’ WHERE LastName = ‘Hansen’
a. SAVE Persons SET LastName = ‘Hansen’ INTO LastName = ‘Nilsen’
70. Which one of the following correctly selects rows from the table myTable that have NULL in column column1?
Answers:
a. SELECT * FROM myTable WHERE column1 IS NULL
a. SELECT * FROM myTable WHERE column1 = NULL
a. SELECT * FROM myTable WHERE column1 EQUALS NULL
a. SELECT * FROM myTable WHERE column1 NOT NULL
a. SELECT * FROM myTable WHERE column1 CONTAINS NULL
71. Is the FROM clause necessary in every SELECT statement?
Answers:
a. Yes
a. No
72. Which command will make a backup on the whole database except the tables sessions and log?
Answers:
a. mysqldump db_name sessions log > backup.sql
a. mysqldump db_name | grep -vv -E “sessions|log” > backup.sql
a. mysqldump db_name –ignore-table db_name.sessions db_name.log > backup.sql
a. mysqldump db_name –except-table=db_name.sessions –except-table=db_name.log > backup.sql
No comments:
Post a Comment