Upwork Test Answers: Get all the correct answers of most recent and possible Upwork Tests A to Z (Updated on Jan, 2016)
Cover Letter Templates: These cover letter samples are not only for Upwork job, but also you will have some idea about your real life job
Freelance Profile Overviews: Different Profile samples and overviews of experts, advanced and intermediate level freelancers
For Newbie of Upwork: Upwork Help - How to apply for a job in Upwork with 10 most important articles about Upwork

A to Z View - All Upwork Test Answers

Upwork MySQL Test Answers

Here you will find all the MySQL Test Answers of Upwork Databases Category with a complete video of Upwork test exam (click here to get the video link of this tests), please press Ctrl + F to find your desired answers of the MySQL Test

1. Which of the following are true in case of Indexes for MYISAM Tables?
Answers: • Indexes can have NULL values or • BLOB and TEXT columns can be indexed

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: • select * from messages group by name Result: 1 A A_data_1 4 B B_data_1 6 C C_data_1

3. How can an user quickly rename a MySQL database for InnoDB?
Answers: • 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: • Yes

5. Consider the following tables:







popularityrating (the popularity of the book on a scale of 1 to 10)

language (such as French, English, German etc)




subject (such as History, Geography, Mathematics etc)






Which is the query to determine the Authors who have written at least 1 book with a popularity rating of less than 5?
Answers: • select authorname from authors where authorid in (select authorid from books where popularityrating<5)

6. The Flush statement cannot be used for:
Answers: • Closing open connections

7. Consider the query:


FROM Students

WHERE name LIKE '_a%';

Which names will be displayed?
Answers: • Names containing "a" as the second lette

8. Which of the following is the best MySQL data type for currency values?
Answers: • DECIMAL(19,4)

9. What are MySQL Spatial Data Types in the following list?
Answers: • GEOMETRY

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: • The two statements produce identical results

11. Which of the following will raise MySQL's version of an error?
Answers: • SIGNAL

12. Which query will return values containing strings "Pizza", "Burger", or "Hotdog" in the database?
Answers: • SELECT * FROM fiberbox WHERE field LIKE '%Pizza%' OR field LIKE '%Burger%' OR field LIKE '%Hotdog%';

13. Which datatype is used to store binary data in MySQL?
Answers: • BLOB

14. Which of the following will reset the MySQL password for a particular user?
Answers: • None of the above.

15. Which of the following is the best way to modify a table to allow null values?
Answers: • ALTER TABLE table_name MODIFY column_name varchar(255) null

16. Which of the following will dump the whole MySQL database to a file?
Answers: • None of the above.

17. Which of the following statements is true regarding character sets in MySQL?
Answers: • None of these.

18. Which of the following is an alternative to groupwise maximum ranking (ex. ROW_NUMBER() in MS SQL)?
Answers: • Using self-join

19. Consider the following tables:

PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)

Subject (such as History, Geography, Mathematics etc)


Which query will determine how many books have a popularity rating of more than 7 on each subject?
Answers: • 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: • Wrapping all variables containing user input by a call to mysql_real_escape_string() makes the code immune to SQL injections.

21. Which of the following is an alternative to Subquery Factoring (ex. the 'WITH' clause in MS SQL Server)?
Answers: • The 'INNER JOIN' clause

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            |

Which of the following will select the highest-priced record per item?
Answers: • select item, brand, price from items where max(price) order by item

23. Which of the following will restore a MySQL DB from a .dump file?
Answers: • mysql -u<user> -p<password> < db_backup.dump

24. Which of the following will show when a table in a MySQL database was last updated?
Answers: • Using the following query: SELECT UPDATE_TIME FROM information_schema.tables WHERE TABLE_SCHEMA = 'database_name' AND TABLE_NAME = 'table_name'

25. Which of the following results in 0 (false)?

26. Which of the following relational database management systems is simple to embed in a larger program?
Answers: • SQLite

27. What is true about the ENUM data type?
Answers: • An enum may contain number enclosed in quotes

28. What will happen if two tables in a database are named rating and RATING?
Answers: • This depends on lower_case_table_names system variable

29. How can a InnoDB database be backed up without locking the tables?
Answers: • mysqldump --single-transaction db_name

30. What does the term "overhead" mean in MySQL?
Answers: • Temporary diskspace that the database uses to run some of the queries

31. Consider the following select statement and its output:

SELECT * FROM table1 ORDER BY column1;










Given the above output, which one of the following commands deletes 3 of the 5 rows where column1 equals 2?
Answers: • DELETE FROM table1 WHERE column1=2 LIMIT 3

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);

Which of the following statements is true?
Answers: • 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: • An in-memory storage engine offering high-availability and data-persistence features

34. Which of the following statements are true?
Answers: • Names of databases, tables and columns 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: • ALTER TABLE

36. What does DETERMINISTIC mean in the creation of a function?
Answers: • The function always returns the same value for the same input

37. Which of the following statements grants permission to Peter with password Software?
Answers: • GRANT ALL ON 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: • 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: • Use the SQL_NO_CACHE option in the query.

40. What is the maximum size of a row in a MyISAM table?
Answers: • 65,534

41. Can you run multiple MySQL servers on a single machine?
Answers: • Yes

42. Which of the following formats does the date field accept by default?
Answers: • YYYY-MM-DD

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: • False

44. What is the name of the utility used to extract NDB configuration information?
Answers: • ndb_config

45. Which one of the following must be specified in every DELETE statement?
Answers: • Table Name

46. Which of the following are not Numeric column types?
Answers: • LARGEINT

47. Which of the following statements is true regarding multi-table querying in MySQL?
Answers: • 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: • The id column cannot be auto incremented because it has not been defined as a primary key

49. Consider the following table definition:
        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: • ALTER TABLE table1 ADD column2a INT AFTER column2

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: • SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);

51. What privilege do you need to create a function?

52. What is wrong with the following query:

select * from Orders where OrderID = (select OrderID from OrderItems where ItemQty > 50)
Answers: • The sub query can return more than one row, so, '=' should be replaced with 'in'

53. Which of the following is a correct way to show the last queries executed on MySQL?
Answers: • 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

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: • Select * from Products order by ProductGroup,CurrentStock DESC

55. What is the correct SQL syntax for returning all the columns from a table named "Persons" sorted REVERSE alphabetically by "FirstName"?
Answers: • 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

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: • 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: • 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: • Select course from students group by course having count(*) > 5;

59. MySQL supports 5 different int types. Which one takes 3 bytes?
Answers: • MEDIUMINT

60. Which of the following is the correct way to determine duplicate values?
Answers: • 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: • .25

62. Which of the following commands will list the tables of the current database?
Answers: • SHOW TABLES

63. Which of the following is not a MySQL statement?
Answers: • ENUMERATE

64. When running the following SELECT query:

    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: • SELECT ID FROM ( SELECT ID, name FROM ( SELECT * FROM employee ) AS T ) AS T;

65. Which of the following is not a Table Storage specifier in MySQL?
Answers: • STACK

66. The REPLACE statement is:
Answers: • 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

67. If you try to perform an arithmetic operation on a column containing NULL values, the output will be:
Answers: • NULL

68. Which of the following is the best way to insert a row, and to update an existing row, using a MySQL query?
Answers: • Use INSERT ... ON DUPLICATE KEY UPDATE statement

69. How will you change "Hansen" into "Nilsen" in the LastName column in the Persons Table?
Answers: • UPDATE Persons SET LastName = 'Nilsen' WHERE LastName = 'Hansen'

70. Which one of the following correctly selects rows from the table myTable that have NULL in column column1?
Answers: • SELECT * FROM myTable WHERE column1 IS NULL

71. Is the FROM clause necessary in every SELECT statement?
Answers: • No

72. Which command will make a backup on the whole database except the tables sessions and log?

Answers: • mysqldump db_name --ignore-table db_name.sessions db_name.log > backup.sql

No comments:

Post a Comment