MySQL UpWork Test Answers
1. What is the correct order of clauses in the select statement?
Answers:
- Indexes can have NULL values
- BLOB and TEXT columns can be indexed
- Indexes per table cannot be more than 16
- 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
————————-
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 (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
- select * from messages where name =Desc Result: 1 A A_data_1 2 A A_data_2 3 A A_data_3
- select * from messages group by name Result: 1 A A_data_1 4 B B_data_1 6 C C_data_1
- Answer A and B
3. How can an user quickly rename a MySQL database for InnoDB?
Answers:
- He cannot rename any MySQL database
- By using: RENAME DATABASE db_old_name TO db_new_name
- By using: RENAME DATABASE TO db_new_name
- 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:
- No
- 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?
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)
- select authorname from authors where authorid in (select authorid from books where popularityrating<=5)
- select authorname from authors where authorid in (select bookid from books where popularityrating<5)
- 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:
- Closing any open tables in the table cache
- Closing open connections
- Flushing the log file
- Flushing the host cache
7. Consider the query:
SELECT name
FROM Students
WHERE name LIKE ‘_a%’;
Which names will be displayed?
Which names will be displayed?
Answers:
- Names starting with “a”
- Names containing “a” as the second lette
- Names starting with “a” or “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:
- SMALLINT
- DECIMAL(19,4)
- VARCHAR(32)
- BIGINT
9. What are MySQL Spatial Data Types in the following list?
Answers:
- GEOMETRY
- CIRCLE
- SQUARE
- POINT
- 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:
- The two statements produce identical results
- The second statement returns an error
- There is no need to specify DESC because the results are sorted in descending order by default
- None of the above statments is correct
11. Which of the following will raise MySQL’s version of an error?
Answers:
- SIGNAL
- RAISE
- ERROR
- None of these.
12. Which query will return values containing strings “Pizza”, “Burger”, or “Hotdog” in the database?
Answers:
- SELECT * FROM fiberbox WHERE field REGEXP ‘Pizza|Burger|Hotdog’;
- SELECT * FROM fiberbox WHERE field LIKE ‘%Pizza%’ OR field LIKE ‘%Burger%’ OR field LIKE ‘%Hotdog%’;
- SELECT * FROM fiberbox WHERE field = ‘%Pizza%’ OR field = ‘%Burger%’ OR field = ‘%Hotdog%’;
- SELECT * FROM fiberbox WHERE field = ‘?Pizza?’ OR field = ‘?Burger?’ OR field = ‘?Hotdog?’;
13. Which datatype is used to store binary data in MySQL?
Answers:
- BLOB
- BIGINT
- INT
- Both BLOB and BIGINT
14. Which of the following will reset the MySQL password for a particular user?
Answers:
- UPDATE mysql.user SET Password=PASSWORD(‘password’) WHERE User=’username’;
- UPDATE mysql.user SET Password=’password’ WHERE User=’username’;
- UPDATE mysql.user SET Password=RESET(‘password’) WHERE User=’username’;
- 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
- ALTER TABLE table_name MODIFY column_name VARCHAR(255)
- ALTER TABLE table_name CHANGE column_name column_name type DEFAULT NULL
- ALTER table_name MODIFY column_name varchar(255) null
16. Which of the following will dump the whole MySQL database to a file?
Answers:
- mysql -e “select * from myTable” -u myuser -pxxxxxxxxx mydatabase > mydumpfile.txt
- mysql -e “select * from myTable” mydatabase > mydumpfile.txt
- SELECT * from myTable FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘n’
- None of the above.
17. Which of the following statements is true regarding character sets in MySQL?
Answers:
- The default character set of MySQL is UTF-8.
- lang.cnf sets the default character set for MySQL databases.
- SET CHARSET utf8 will set the character set of data to be imported to UTF-8.
- None of these.
18. Which of the following is an alternative to groupwise maximum ranking (ex. ROW_NUMBER() in MS SQL)?
Answers:
- Using subqueries
- Using variables in a MySQL query
- Using self-join
- 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:
- select subject,count(*) as Books from books,subjects where books.popularityrating > 7
- select subject,count(*) as Books from books,subjects where books.authorid=subjects.authorid and books.popularityrating > 7 group by subjects.subject
- select subject,count(*) as Books from books,subjects where books.subjectid=subjects.subjectid and books.popularityrating = 7 group by subjects.subject
- 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.
- Parametrized queries do not make code less vulnearable to SQL injections.
- SQL injections are not possible, if only emulated prepared statements are used.
- 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:
- The ‘IN’ clause
- Using temporary tables and inline views
- The ‘INNER JOIN’ clause
- 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:
- select item, brand, price from items where max(price) order by item
- select * from items where price = max group by item
- select item, brand, max(price) from items group by item
- select * from items where price > 200 order by item
23. Which of the following will restore a MySQL DB from a .dump file?
Answers:
- mysql -u<user> -p < db_backup.dump
- mysql -u<user> -p<password> < db_backup.dump
- mysql -u<user> -p <password> < db_backup.dump
- 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’
- Creating an on-update trigger to write timestamp in a custom table, then querying the custom table
- Getting the “last modified” timestamp of the corresponding database file in the file system
- None of these.
25. Which of the following results in 0 (false)?
Answers:
- “EXPERTRATING” LIKE “EXP%”
- “EXPERTRATING” LIKE “Exp%”
- BINARY “EXPERTRATING” LIKE “EXP%”
- BINARY “EXPERTRATING” LIKE “Exp%”
- All will result in 1 (true)
26. Which of the following relational database management systems is simple to embed in a larger program?
Answers:
- MySQL
- SQLite
- Both
- None
27. What is true about the ENUM data type?
Answers:
- An enum value may be a user variable
- An enum may contain number enclosed in quotes
- An enum cannot contain an empty string
- An enum value may be NULL
- None of the above is true
28. What will happen if two tables in a database are named rating and RATING?
Answers:
- This is not possible as table names are case in-sensitive (rating and RATING are treated as same name)
- This is possible as table names are case sensitive (rating and RATING are treated as different names)
- This is possible on UNIX/LINUX and not on Windows platform
- This is possible on Windows and not on UNIX/LINUX platforms
- 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
- mysqldump –force db_name
- mysqldump –quick db_name
- mysqldump –no-tablespaces db_name
30. What does the term “overhead” mean in MySQL?
Answers:
- Temporary diskspace that the database uses to run some of the queries
- The size of a table
- A tablespace name
- None of the above
31. Consider the following select statement and its output:
SELECT * FROM table1 ORDER BY column1;
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?
Given the above output, which one of the following commands deletes 3 of the 5 rows where column1 equals 2?
Answers:
- DELETE FIRST 4 FROM table1 WHERE column1=2
- DELETE 4 FROM table1 WHERE column1=2
- DELETE WHERE column1=2 LIMIT 4
- DELETE FROM table1 WHERE column1=2 LIMIT 3
- 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:
- Two tables are created
- 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
- Those queries are invalid
- 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
- A filesystem
- An SQL superset
- MySQL scripting language
- None of the above
34. Which of the following statements are true?
Answers:
- Names of databases, tables and columns can be up to 64 characters in length
- Alias names can be up to 255 characters in length
- Names of databases, tables and columns can be up to 256 characters in length
- 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:
- CHANGE TABLE
- MODIFY TABLE
- ALTER TABLE
- UPDATE TABLE
36. What does DETERMINISTIC mean in the creation of a function?
Answers:
- The function returns no value
- The function always returns the same value for the same input
- The function returns the input value
- None of the above
37. Which of the following statements grants permission to Peter with password Software?
Answers:
- GRANT ALL ON testdb.* TO peter PASSWORD ‘Software’
- GRANT ALL ON testdb.* TO peter IDENTIFIED by ‘Software’
- GRANT ALL OF testdb.* TO peter PASSWORD ‘Software’
- 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:
- EMPNO, unique value of ENAME and then SALARY are displayed
- EMPNO, unique value ENAME and unique value of SALARY are displayed
- DISTINCT is not a valid keyword in SQL
- 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:
- Add the /*!no_query_cache*/ comment to the query.
- Flush the whole cache with the command: FLUSH QUERY CACHE
- Reset the query cache with the command: RESET QUERY CACHE
- Use the SQL_NO_CACHE option in the query.
40. What is the maximum size of a row in a MyISAM table?
Answers:
- No limit
- OS specific
- 65,534
- 2’147’483’648
- 128
41. Can you run multiple MySQL servers on a single machine?
Answers:
- No
- Yes
42. Which of the following formats does the date field accept by default?
Answers:
- DD-MM-YYYY
- YYYY-DD-MM
- YYYY-MM-DD
- MM-DD-YY
- 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.
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:
- True
- False
44. What is the name of the utility used to extract NDB configuration information?
Answers:
- ndb_config
- cluster_config
- ndb –config
- configNd
- None of the above
45. Which one of the following must be specified in every DELETE statement?
Answers:
- Table Name
- Database name
- LIMIT clause
- WHERE clause
46. Which of the following are not Numeric column types?
Answers:
- BIGINT
- LARGEINT
- SMALLINT
- DOUBLE
- DECIMAL
47. Which of the following statements is true regarding multi-table querying in MySQL?
Answers:
- JOIN queries are faster than WHERE queries.
- WHERE queries are faster than JOIN queries.
- INNER queries are faster than JOIN queries.
- 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:
- Nothing
- The id column cannot be auto incremented because it has not been defined as a primary key
- 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:
- ALTER TABLE table1 ADD column2a INT AFTER column2
- MODIFY TABLE table1 ADD column2a AFTER column2
- INSERT INTO table1 column2a AS INT AFTER column2
- ALTER TABLE table1 INSERT column2a INT AFTER column2
- CHANGE TABLE table1 INSERT column2a BEFORE column3
- Columns are always added after the last column
50. Examine the data in the employees table given below:
last_name department_id salary
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?
Which of the following Subqueries will execute well?
Answers:
- SELECT * FROM employees where salary > (SELECT MIN(salary) FROM employees GROUP BY department_id);
- SELECT * FROM employees WHERE salary = (SELECT AVG(salary) FROM employees GROUP BY department_id);
- SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
- SELECT department_id FROM employees WHERE SALARY > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);
- 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:
- UPDATE
- CREATE ROUTINE
- SELECT
- CREATE FUNCTION
- No specific privilege
52. What is wrong with the following query:
select * from Orders where OrderID = (select OrderID from OrderItems where ItemQty > 50)
Answers:
- In the sub query, ‘*’ should be used instead of ‘OrderID’
- The sub query can return more than one row, so, ‘=’ should be replaced with ‘in’
- The sub query should not be in parenthesis
- None of the above
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
- Edit the MySQL config file (mysql.con) and add the following line log = /var/log/mysql/mysql.log
- Execute VIEW .mysql_history
- 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:
- Select * from Products order by CurrentStock,ProductGroup
- Select * from Products order by CurrentStock DESC,ProductGroup
- Select * from Products order by ProductGroup,CurrentStock
- Select * from Products order by ProductGroup,CurrentStock DESC
- 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:
- SELECT * FROM Persons WHERE FirstName ORDER BY FirstName DESC
- SELECT * FROM Persons SORT REVERSE ‘FirstName’
- SELECT * FROM Persons ORDER BY -‘FirstName’
- 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?
Which of the following statements should you use?
Answers:
- SELECT book_title FROM books WHERE price between 500 and 900 AND purchase_date < ‘2002-11-11’ ORDER BY purchase_date;
- SELECT book_title FROM books WHERE price IN (500, 900) AND purchase_date< ‘2002-11-11’ ORDER BY purchase date ASC;
- SELECT book_title FROM books WHERE price < 500 OR>900 AND purchase_date DESC;
- 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
Transactions and commit/rollback are supported by MySQL using the MyISAM engine
Answers:
- True
- 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?
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 where count(course) > 5;
- Select course from students where count(*) > 5 group by course;
- Select course from students group by course;
- Select course from students group by course having count(*) > 5;
- Select course from students group by course where count(*) > 5;
- Select course from students where count(group(course)) > 5;
- Select count(course) > 5 from students;
- None of the above
59. MySQL supports 5 different int types. Which one takes 3 bytes?
Answers:
- TINYINT
- MEDIUMINT
- SMALLINT
- INT
- BIGINT
60. Which of the following is the correct way to determine duplicate values?
Answers:
- SELECT column_duplicated, sum(*) amount FROM table_name WHERE amount > 1 GROUP BY column_duplicated
- SELECT column_duplicated, COUNT(*) amount FROM table_name WHERE amount > 1 GROUP BY column_duplicated
- SELECT column_duplicated, sum(*) amount FROM table_name GROUP BY column_duplicated HAVING amount > 1
- 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:
- 4
- 2
- 1
- .5
- .25
- 8
- 24
62. Which of the following commands will list the tables of the current database?
Answers:
- SHOW TABLES
- DESCRIBE TABLES
- SHOW ALL TABLES
- LIST TABLES
63. Which of the following is not a MySQL statement?
Answers:
- ENUMERATE
- EXPLAIN
- KILL
- LOAD DATA
- 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?
Which of the following is the best solution for this error?
Answers:
- SELECT ID FROM ( SELECT ID AS SECOND_ID, name FROM ( SELECT * FROM employee ) );
- SELECT ID FROM ( SELECT ID, name AS NAME FROM ( SELECT * FROM employee ) );
- SELECT ID FROM ( SELECT ID, name FROM ( SELECT * FROM employee ) AS T ) AS T;
- 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:
- InnoDB
- MYISAM
- BLACKHOLE
- STACK
66. The REPLACE statement is:
Answers:
- Same as the INSERT statement
- 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
- 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:
- NULL
- An error will be generated
- 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:
- Use MERGE statement
- Use INSERT … ON DUPLICATE KEY UPDATE statement
- Use ADD UNIQUE statement
- Use REPLACE 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’
- UPDATE Persons SET LastName = ‘Hansen’ INTO LastName = ‘Nilsen’
- SAVE Persons SET LastName = ‘Nilsen’ WHERE LastName = ‘Hansen’
- 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:
- SELECT * FROM myTable WHERE column1 IS NULL
- SELECT * FROM myTable WHERE column1 = NULL
- SELECT * FROM myTable WHERE column1 EQUALS NULL
- SELECT * FROM myTable WHERE column1 NOT NULL
- SELECT * FROM myTable WHERE column1 CONTAINS NULL
71. Is the FROM clause necessary in every SELECT statement?
Answers:
- Yes
- No
72. Which command will make a backup on the whole database except the tables sessions and log?
Answers:
- mysqldump db_name sessions log > backup.sql
- mysqldump db_name | grep -vv -E “sessions|log” > backup.sql
- mysqldump db_name –ignore-table db_name.sessions db_name.log > backup.sql
- mysqldump db_name –except-table=db_name.sessions –except-table=db_name.log > backup.sql
73.Which of the following statements is true?
Answers:
- Replication can be a part of a load balancing strategy.
- Replication and clustering are complete synonyms in the context of MySQL server administration.
- MySQL supports only master-slave replication.
- MySQL does not support master-master replication.
74. Which of the following is not a valid Arithmetic operator?
Answers:
- +
- –
- *
- \
- %
- All are valid
- GEOMETRY
- CIRCLE
- SQUARE
- POINT
- POLYGON
- Alias names are case sensitive
- Alias names are case sensitive
- Alias names are case in-sensitive
- Alias names are case sensitive on UNIX and not on Windows
- Alias names are case sensitive on Windows and not on UNIX
- Alias names case sensitivity depends on lower_case_table_names system setting
- SUM(start_date)
- AVG(start_date)
- COUNT(start_date)
- AVG(start_date, end_date)
- AVG(start_date, end_date)
- MIN(start_date)
- Add the following lines in my.cnf:
- dd the following lines in my.cnf:
[mysqld]
character_set_server = utf8 - Add the following lines in my.cnf:
[mysqld]
skip-character-set-client-handshake
character_set_client=utf8
character_set_server=utf8 - AVG(start_date, end_date)
- AVG(start_date, end_date)
- MIN(start_date)
- «This is the «quoted» message»
- «This is the «»quoted»» message»
- ‘This is the «quoted» message’
- «This is the \»quoted\» message»
- It returns employees whose salary is 50% more than $23,000
- It returns employees who have 50% commission rate or salary greater than $23,000
- It returns employees whose salary is 50% less than $23,000
- None of the above
- Create the target database using MySQLAdmin,
- Execute the following MySql query CREATE TABLE t2 SELECT * FROM t1;
- Execute the following MySql query CREATE TABLE x LIKE other_db.y;
- CREATE TABLE DB2 SELECT * FROM DB1;
- SELECT «EXPERTRATING» LIKE «EXP%»
- SELECT «EXPERTRATING» LIKE «Exp%»
- SELECT BINARY «EXPERTRATING» LIKE «EXP%»
- SELECT BINARY «EXPERTRATING» LIKE «Exp%»
- All will result in 1 (true)
- select * from Pers where joining_date from #1/1/2005# to #1/2/2005#, job=Analyst or clerk or salesman
- select * from Pers where joining_date between #1/1/2005# to #1/2/2005#, job=Analyst or job=clerk or job=salesm
- select * from Pers where joining_date between #1/1/2005# and #1/2/2005# and
- None of the above
- mysqldump –single-transaction db_name
- mysqldump –force db_name
- mysqldump –quick db_name
- mysqldump –no-tablespaces db_name
- &
- &&
- <<
- |
- >>
- InnoDB is thread safe
- InnoDB provides a transaction safe environment
- InnoDB can handle table with more than 1000 columns
- InnoDB provides FULLTEXT indexes
- None of the above
- 1
- 2
- 3
- 4
- 5
- Nothing will happen
- MySQL will generate an error
- MySQL will convert all varchar datatypes into char
- MySQL will convert all char datatypes into varchar
- 0000
- 1900
- 2000
- Ambiguous, cannot be determined
- True, only can create migration solution in .NET programming language.
- True, it can be solve by migration solution. These solutions vary by programming language.
- Both A and B
- None of the above
- &
- &&
- AND
- NOT
- For one TIMESTAMP column in a table, you can assign the current timestamp as the default value and the auto-update value
- TIMESTAMP columns are NOT NULL by default, cannot contain NULL values, and assigning NULL assigns the current timestamp
- When the server runs with the MAXDB SQL mode enabled, TIMESTAMP is identical with DATETIME
- A TIMESTAMP column cannot have a default value
- None of the above is true
- Between..and..
- Like
- In
- Is null
- Not in
- All of the above are SQL operators
- Between..and..
- Like
- In
- Is null
- Not in
- All of the above are SQL operators
- ==
- <=>
- !=
- <>
- REGEXP
- All of the above are SQL operators
- It will display the current date
- It will display the error message as now does not exist.
- It will display a syntax error near ‘()’
- 6
- 5
- 4
- 3
- SELECT * FROM Persons WHERE LastName > ‘Hansen’, LastName <‘Pettersen’
- SELECT LastName > ‘Hansen’ AND LastName < ‘Pettersen’ FROM Persons
- SELECT * FROM persons WHERE LastName > ‘Hansen’ AND LastName > ‘Pettersen’
- SELECT * FROM Persons WHERE LastName BETWEEN ‘Hansen’ AND ‘Pettersen’
- Using the older syntax is more subject to error. If use inner joins without an ON clause, will get a syntax error.
- INNER JOIN is ANSI syntax. It is generally considered more readable, especially when joining lots of tables. It can also be easily replaced with an OUTER JOIN whenever a need arises
- (INNER JOIN) ON will filter the data before applying WHERE clause. The subsequent join conditions will be executed with filtered data which makes better performance. After that only WHERE condition will apply filter conditions.
- All of the Above
- Yes
- No
- SELECT MAX(GPA) FROM STUDENT_GRADES WHERE GPA IS NOT NULL
- SELECT GPA FROM STUDENT_GRADES GROUP BY SEMESTER_END
- SELECT MAX(GPA) FROM STUDENT_GRADES GROUP BY SEMESTER_END
- SELECT TOP 1 GPA FROM STUDENT_GRADES GROUP BY SEMESTER_END
- None of the above
- Select * from students where marks > avg(marks);
- Select * from students order by marks where subject = ‘SQL’;
- Select * from students having subject =’SQL’;
- Select name from students group by subject, name;
- Select group(*) from students;
- Select name,avg(marks) from students;
- None of the above
- Avg
- Select
- Order By
- Sum
- Union
- Group by
- Having
- BLOB and TEXT columns cannot have DEFAULT values
- BLOB columns are treated as binary strings (byte strings)
- BLOB columns have a charset
- TEXT columns cannot be indexed
- None of the above is true
- (a) is correct
- (b) is correct
- (a) and (b) both are correct
- (a) and (b) both are incorrect
- (a) and (b) both are incorrect
- +
- —
- /
- *
- No
- Yes
- Command D removes all entries, Command T removes entries inserted since last commit.
- Command D removes all entries, Command T removes all entries and resets auto-increment counters.
- Command D removes all entries, Command T removes all entries and deletes table meta data.
- Command D removes all entries, Command T recalculates indexes
- dual join
- right join
- natural join
- middle join
- STRAIGHT_JOIN
- Because the username is contained in the password
- Because it is granting all privileges to a user that is not the root
- Because it is granting access from any IP address
- Because the username ‘john’ does not fully identify the user
- In the sub query, ‘*’ should be used instead of ‘OrderID’
- The sub query can return more than one row, so, ‘=’ should be replaced with ‘in’
- The sub query should not be in parenthesis
- None of the above
- Run the following query: SELECT * FROM * WHERE * LIKE ‘%owner%’
- Create an SQL dump of the database and its data, then search the dump file for occurrences of “owner” using an appropriate text editor or appropriate command line tools.
- Discover tables using the “SHOW TABLES” query; then for each table discover its columns using “SHOW COLUMNS FROM” query; then for each column run the query: SELECT * FROMWHERE like ‘%owner%’ Call the searchAllDB($search) function
- None of the above
- A SET can have zero or more values
- A SET value may contain a comma
- A SET can have a maximum of 64 different members
- MySQL stores SET values as strings
- None of the above is true
- 1,2,3,4,5
- 1,3,5,4,2
- 1,3,5,2,4
- 1,3,2,5,4
- 1,5,2,3,4
- 1,4,2,3,5
- 1,4,3,2,5
- John Smith Peter NULL NULL Brown
- John Smith Peter NULL
- John Smith NULL Brown
- John Smith Peter Brown
- SELECT name, location FROM `venues` as v LEFT JOIN `events` as e ON e.venue_id = v.id;
- SELECT name, location FROM `venues` AS v INNER JOIN `events` AS e ON e.venue_id = v.id;
- SELECT name, location FROM `venues` as v, `events` as e WHERE e.venue_id = v.id;
- SELECT name, location FROM `events` AS e RIGHT JOIN `venues` AS v ON v.id =e.venue_id;
- SELECT name, location FROM `venues` UNION (SELECT id, venue_id FROM `events`);
- show procedure status;
- show variables like ‘%procedure%’;
- select * from procedures;
- show all procedures;
- BINARY
- NOT
- <<
- %
- CHAR(0)
- NOT
- CHAR(1024)
- CHAR(256)
- CHAR(256)
- VARCHAR(-1024)
- All are invalid
- All are valid
- SELECT hobbies
FROM people_hobbies; - SELECT CONCAT_WS(*)
FROM people_hobbies; - SELECT person_id, GROUP_CONCAT(hobbies separator ‘, ‘)
FROM peoples_hobbies GROUP BY person_id; - SELECT CONCAT(hobbies separator ‘, ‘)
FROM people_hobbies; - SELECT hobbies
FROM people_hobbies; - SELECT CONCAT_WS(*)
FROM people_hobbies; - SELECT person_id, GROUP_CONCAT(hobbies separator ‘, ‘)
FROM peoples_hobbies GROUP BY person_id; - SELECT CONCAT(hobbies separator ‘, ‘)
FROM people_hobbies; - +—-+——+
| id | u |
+—-+——+
| 1 | 20 |
+—-+——+ - +—-+——+
| id | u |
+—-+——+
| 2 | 10 |
+—-+——+ - +—-+——+
| id | u |
+—-+——+
| 2 | 20 |
+—-+——+ - Syntax error message
- GREATEST(a,b)
- MAX(a,b)
- MAXIMUM(a,b)
- HIGHER(a,b)
- The value displayed in the CALC_VALUE column will be lowe
- The value displayed in the CALC_VALUE column will be highe
- There will be no difference in the value displayed in the CALC_VALUE column
- An error will be reported
- SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME = ‘APPLICATIONS’ AND REFERENCED_COLUMN_NAME = ‘ID’ AND TABLE_SCHEMA=’PROD_DB’;
- SELECT * FROM ALL_TABLES.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME = ‘APPLICATIONS’ AND REFERENCED_COLUMN_NAME = ‘ID’ AND TABLE_SCHEMA=’PROD_DB’;
- SELECT * FROM ALL_TABLES.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME = ‘APPLICATIONS’ AND REFERENCED_COLUMN_NAME = ‘ID’;
- SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE = ‘APPLICATIONS’ AND REFERENCED_COLUMN = ‘ID’ AND SCHEMA=’PROD_DB’;
- UPDATE T1
LEFT JOIN
T2
ON T2.ID = T1.ID
SET T1.COL1 = NEWVALUE
WHERE T2.ID IS NULL - UPDATE T1
LEFT JOIN
T2
SET T1.COL1 = NEWVALUE
ON T2.ID = T1.ID
WHERE T2.ID IS NULL - UPDATE T1
LEFT JOIN
T2
ON T2.ID = T1.ID
WHERE T2.ID IS NULL
SET T1.COL1 = NEWVALUE - UPDATE T1, T2
LEFT JOIN
ON T2.ID = T1.ID
SET T1.COL1 = NEWVALUE
WHERE T2.ID IS NULL - The correct use of REPAIR TABLE to rebuild .myi files is:
REPAIR TABLE sometable USE_FRM; - MySQL DBs can be restored directly from those files.
- Those files will recover the database, but not the index file.
- Those files will only recover the database blob field data.
- EMPNO, unique value of ENAME and then SALARY are displayed
- MySQL DBs can be restored directly from those files.
- EMPNO, unique value ENAME and unique value of SALARY are displayed
- DISTINCT is not a valid keyword in SQL
- No values will be displayed because the statement will return an error
- Author probably intent to retrieve empty set value.
- Easier way to generate complex WHERE statements — 1=1 is true always (NOT NULL), so all other conditions can be append with AND clause.
- It may even help the optimazation of the query very much.
- Not always true expression.
- Yes, use SELECT identifier, GROUP_CONCAT (string SEPARATOR ‘ ’) FROM table_name GROUP BY identifier.
- No.
- Yes, use SELECT identifier, CONCAT (string, ‘’) FROM table_name GROUP BY identifier.
- Yes, use SELECT identifier, STRING_CONCAT (string SEPARATOR ‘ ’) FROM table_name GROUP BY identifier.
- TEXT datatype can store more characters then VARCHAR datatype
- TEXT datatype supports binary and non-binary string storages but VARCHAR supports only binary strings
- TEXT is stored outside the mysql row and VARCHAR is stored as part of the row
- Max length of VARCHAR datatype is 16,777,215 characters
- Cannot modify the same table which was used in the SELECT part.
- Select the rows not to be deleted into an empty table that has the same structure as the original table:
INSERT INTO t_copy SELECT * FROM t WHERE … ; - Both A and B
- DELETE FROM somelog WHERE user = ‘jcole’
ORDER BY timestamp_column LIMIT 1; - Char
- Binary
- Varchar
- Varbinary
- INSERT INTO table VALUES is performance-optimized while INSERT INTO table SET is not.
- INSERT INTO table SET is performance-optimized while INSERT INTO table VALUES is not.
- Both are equal in performance.
- INSERT INTO table VALUES is performance-optimized for MyISAM while INSERT INTO table SET is performance-optimized for InnoDB.
- By specifying on the command line:
Mysql —max_allowed_packet=32M - By specifying on the command line:
Mysql —max_allowed_packet=100M -u root - By specifying on the command line:
Mysql —max_allowed_packet=100M -u root -p database < dump.sql
And updating the my.cnf or my.ini files with the following lines:
set global net_buffer_length=1000000;
set global max_allowed_packet=1000000000; - By updating my.ini file with the following line:
set global net_buffer_length=32000; - To debug syntax errors in queries.
- To analyze the execution of a query.
- To automatically optimize a query.
- To get the documentation entry for a specific command.
- SELECT count(*) FROM information_schema.columns WHERE data_type = ‘enum’;
- select count(*) from information_schema.column where column_name=»ENUM(‘M’,’F’,’NA’)»;
- SELECT count(*) FROM information_schema.columns WHERE data_type = «ENUM(‘M’,’F’,’NA’)» ;
- SELECT count(*) FROM information_schema.columns WHERE column_type = «ENUM(‘M’,’F’,’NA’)» ;
- SELECT toD.dom_url AS ToURL,
fromD.dom_url AS FromUrl,
rvw.*
FROM reviews AS rvw
LEFT JOIN domain AS toD
ON toD.Dom_ID = rvw.rev_dom_for
LEFT JOIN domain AS fromD
ON fromD.Dom_ID = rvw.rev_dom_from - SELECT toD.dom_url AS ToURL,
fromD.dom_url AS FromUrl,
rvw.*
FROM reviews AS rvw
RIGHTJOIN domain AS toD
ON toD.Dom_ID = rvw.rev_dom_for
RIGHTJOIN domain AS fromD
ON fromD.Dom_ID = rvw.rev_dom_from - SELECT toD.dom_url AS ToURL,
fromD.dom_url AS FromUrl,
rvw.*
FROM reviews AS rvw
FULLJOIN domain AS toD
ON toD.Dom_ID = rvw.rev_dom_for
FULLJOIN domain AS fromD
ON fromD.Dom_ID = rvw.rev_dom_from - It is not possible to join the same table twice in MySQL.
- By using TIMESTAMP (defaul_value TIMESTAMP DEFAULT CURRENT_TIMESTAMP)
- By using DATE (defaul_value DATE DEFAULT CURRENT_DATE)
- By using DATEDEFAULT (defaul_value SET DATEDEFAULT)
- By using DATETIME (defaul_value DATETIME DEFAULT CURRENT_DATETIME)
- SIGNED
- BINARY
- REAL
- BIGINT
- FULL TABLE SCAN
- range
- ALL
- const
- EXTRACT
- SELECT
- GET
- OPEN
- It is not possible to implement database versioning in MySQL.
- Using external version control systems to back up the database files
- Using built-in tools included in MySQL
- None of these.
- The two queries will produce the same output.
- The two queries will produce different outputs.
- An error will be generated while running the two queries.
- None of the above.
- An error is produced as there is no column named ‘_rowid’
- All the rows are fetched and are sorted in a descending order based on the column ‘ID’
- MySQL will return an empty result set
- All the rows are fetched and are not sorted in any order
- 100
- 101
- 150
- 151
- Execute the following command for every table in every database:
OPTIMIZE LOCAL TABLE table_name - Execute the following command for every database:
mysqlcheck -o database_name - Execute the following command:
mysqlcheck -o —all-databases - Execute the following command for every database:
OPTIMIZE DATABASE database_name - ALTER TABLE votes ADD UNIQUE INDEX(user, email, address);
- UNIQUE KEY ‘votes’ (‘user’, ‘email’, ‘address’);
- ALTER TABLE votes ADD UNIQUE (user, email, address);
- Answer A and C
- SELECT * from PERSONS where LASTNAME LIKE ‘JOH%’;
- SELECT * from PERSONS where LASTNAME IS LIKE ‘JOH%’;
- SELECT * from PERSONS where LASTNAME LIKE ‘JOH*’;
- SELECT * from PERSONS where LASTNAME IS LIKE ‘JOH*’;
- The WHERE clause works with aliases, while the HAVING clause does not.
- The HAVING clause works with aliases, while the WHERE clause does not.
- The HAVING clause works with aliases, while the WHERE clause needs to have expressions repeated, and will not work with aggregating functions like SUM.
- The WHERE clause works with aliases, while the HAVING clause needs to have expressions repeated, and will not work with aggregating functions like SUM.
- DATETIME
- TIMEZONE
- TIMESTAMP
- DATE
- SELECT * FROM Customers WHERE FirstName=’b’
- SELECT * FROM Customers WHERE FirstName=’%b%’
- SELECT * FROM Customers WHERE FirstName LIKE ‘b%’
- SELECT * FROM Customers WHERE FirstName LIKE ‘%b’
- BYNARY (60)
- TEXT (60)
- VARCHAR (60)
- VARBINARY (60)
- SELECT TITLE FROM APPLICATIONS ORDER BY RAND() LIMIT 10
- SELECT TITLE FROM APPLICATIONS WHERE RAND() > 10/(SELECT COUNT(*) FROM APPLICATIONS)
- SELECT TITLE FROM APPLICATIONS LIMIT 10 BY RAND()
- SELECT TITLE FROM APPLICATIONS WHERE RAND() > 0.20*(SELECT COUNT(*) FROM APPLICATIONS)
- BLOB
- LONGTEXT
- VARCHAR (4096)
- VARCHAR (4)
- Using a programming language/framework that supports database schema change detection
- Commit SQL scripts with DDL scripts to alter the schema; if there are new scripts, then the database schema has changed.
- Using an (Object-relational mapping) ORM tool
- None of these.
- Using a programming language/framework that supports database schema change detection
- Commit SQL scripts with DDL scripts to alter the schema; if there are new scripts, then the database schema has changed.
- Using an (Object-relational mapping) ORM tool
- None of these.
- Each InnoDB table created using the file-per-table mode goes into its own tablespace file, with a .ibd
- A set of files with names such as ibdata1, ibdata2, and so on, that make up the InnoDB system tablespace.
- A set of files, typically named ib_logfile0 and ib_logfile1, that form the redo log. These files record statements that attempt to change data in InnoDB tables.
- InnoDB system tablespace files can automatically shrink/purge when it reach maximum limit
- MD5
- AES_ENCRYPT
- SHA512
- SHA2
- Super_priv
- Show_db_priv
- Create_tablespace_priv
- Execute_priv
- Permanent tabe
- Temporary Table
- View
- There is no limit to that
- 64
- 32
- 16
- heap_table_size
- max_heap_table_size
- max_table_size
- None of the above.
- 4
- 8
- 12
- 16
- SELECT first_name FROM users WHERE (age=15 OR age=16 OR age=17 OR age=18 OR age=19 OR age=20 OR age=21 OR age=22 OR age=23 OR age=24);
- SELECT first_name FROM users WHERE age IN (15,16,17, 18, 19, 20, 21, 22, 23, 24);
- SELECT first_name FROM users WHERE age BETWEEN 15 AND 24;
- Like I normally do: SELECT nickname FROM users ORDER BY RAND() LIMIT 1;
- I would first run a query to get a total number of rows: SELECT COUNT(*) FROM users;. After that I would select a random number with the scripting language (e.g. mt_rand in case of PHP) and then perform a query like this: SELECT nickname FROM users LIMIT $random_number, 1;
- I would first run a query to get all the nicknames: SELECT nickname FROM USERS;. After that I would select a random nickname with the scripting language (e.g. mt_rand in case of PHP).
- By setting the system variable ‘exec_time_out’ to an integer value
- There is a default value set in milliseconds that cannot be changed
- By setting the system variable ‘max_execution_time’ to an integer value
- The SELECT statements cannot have an execution timeout
- INFORMATION_SCHEMA
- META_SCHEMA
- INFORMATION_METADATA
- METADATA_SCHEMA
- VALUES()
- SPEED()
- BENCHMARK()
- SCHEMA()
- MyISAM
- Memory
- BInnoDB
- SCHEMA()
- MyISAM
- Memory
- BInnoDB
- SCHEMA()
- MyISAM
- Memory
- InnoDB
- Archive
- 80
- 8080
- 3306
- 556
- InnoDB
- ARCHIVE
- MyISAM
- FEDERATED
- A table ‘t2’ is created with List Partitioning
- Failure/Error occurs
- No partitions are created
- A table ‘t2’ is created with List Partitioning
- Failure/Error occurs
- No partitions are created
- SELECT * FROM TABLE_NAME WITH (nolock)
- SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
- No commands are necessary: SELECT statements do not change data, and thus do not cause locks.
- SET TRANSACTION-ISOLATION = READ-UNCOMMITTED
- Select count(*) from EMP where empJoinDate between ‘2012-10-01′ and 2012-12-30’;
- Select count(1) from EMP where empJoinDate between ‘2012-10-01′ and 2012-12-30’;
- Select count(*) from EMP where empJoinDate between ‘2012-10-01′ and 2012-12-30’ group by EXTRACT(YEAR_MONTH from empJoinDate );
- Select sum(1) from EMP where empJoinDate >=»2012-10-01″ and empJoinDate <=»2012-12-30″;
- Non of the above
- Before Insert
- Before Update
- Before Drop
- Before Delete
- 65,535
- 64
- 64,535
- 65
- START TRANSACTION
- COMMIT
- ROLLBACK
- NOCOMMIT
- —line-numbers
- —named-commands, -G
- —pager[=command]
- —execute=statement, -e statement
- 1
- 5
- As per the max value set in environment variables
- There is no upper limit on the number of Auto Increment colums
- It stops incrementing. Any further inserts are going to produce an error, since the key has been used already.
- 5
- It will still increment the value by 1.
- It will reset the auto increment index.
- None of the above.
- When using a fixed-length type such as CHAR(n), stored values require n x 4 bytes for utf8
- MySQL stores metadata in a Unicode character set, namely UTF-8
- It will still increment the value by 1.
- The default MySQL character set is UTF-8
- All statements are true
- $result = mysql_query(“SELECT * from TABLE order by RAND() LIMIT 1”);
- $range_result = mysql_query(«SELECT MAX(`id`) AS max_id , MIN(`id`) AS min_id FROM `table`»);
$range_row = mysql_fetch_object( $range_result );
$random = mt_rand( $range_row->min_id , $range_row->max_id );
$result = mysql_query( » SELECT * FROM `table` WHERE `id` >= $random LIMIT 0,1 «); - $offset_result = mysql_query(«SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM `table`»);
$offset_row = mysql_fetch_object( $offset_result );
$offset = $offset_row->offset
$result = mysql_query(» SELECT * FROM `table` LIMIT $offset, 1 «); - SELECT * FROM `table` WHERE id >= (SELECT FLOOR( MAX(id) * RAND()) FROM `table` ) ORDER BY id LIMIT 1
- MyISAM
- Memory
- InnoDB
- Archive
- .FYI
- frm
- MYD
- .MYI
- It is very quick and easy to cache.
- There are no limitations regarding column types.
- It requires much less disk space than the other two storage formats.
- It is easy to reconstruct after a crash, because rows are located in fixed positions
- The length can be up to 255 bytes, however, it is shared among all columns and the character set used in a row.
- The length can be up to 65,535 bytes, however, it is shared among all columns and the character set used in a row.
- The length can be up to 32,765 bytes, however, it is shared among all columns and the character set used in a row.
- The length can be up to 255 bytes, however, it is shared among all columns and the character set used in a row.
- The length can be up to 65,535 bytes, however, it is shared among all columns and the character set used in a row.
- The length can be up to 32,765 bytes, however, it is shared among all columns and the character set used in a row.
- Double have accuracy up to eight place whereas float upto 18 places
- Floating point numbers are stored in FLOAT whereas Double are stored in DOUBLE.
- Float takes 4 bytes whereas DOUBLE takes eight bytes.
- FLOAT is for single-precision whereas DOUBLE is for double-precision numbers.
- Use «INSERT DELAYED» instead of «INSERT» to record visitors
- Record the data about the visitors into a flat file on the local hard disc drive on the web server. Set up a scheduled job to write multiple records at once into the database.
- Set up a scheduled job to analyze the Apache access.log to retrieve the information about the visitors and write the data into the database, multiple records at once.
- There is no specialized setup necessary; 5-6 simple inserts per second is normal load for a MySQL database.
- SELECT();
SELECT REPLACE(‘stackowerflow’, ‘ower’, ‘over’);
Output: «stackoverflow» - USER DEFINED FUNCTIONS
SELECT regex_replace(‘[^a-zA-Z0-9]+‘, ”, “%$&?/’|test><+-,][)(» ); - Both A and B
- None of the Above.
- SELECT();
SELECT REPLACE(‘stackowerflow’, ‘ower’, ‘over’);
Output: «stackoverflow» - USER DEFINED FUNCTIONS
SELECT regex_replace(‘[^a-zA-Z0-9]+‘, ”, “%$&?/’|test><+-,][)(» ); - Option B:
SELECT *
FROM periods
WHERE range_start <= @check_period_end AND range_end >= @check_period_start - Both options A & B
- None of the above
- select . . .
where locations.lat between X1 and X2
and locations.Long between y1 and y2; - select . . .
where locations.lat between X1 and X2
or locations.Long between y1 and y2; - SELECT *
FROM table
WHERE MBRContains(LineFromText(CONCAT(
‘(‘
, @lon + 10 / ( 111.1 / cos(RADIANS(@lon)))
, ‘ ‘
, @lat + 10 / 111.1
, ‘,’
, @lon — 10 / ( 111.1 / cos(RADIANS(@lat)))
, ‘ ‘
, @lat — 10 / 111.1
, ‘)’ )
,mypoint) - SELECT *
FROM table
WHERE MBRContains(LineFromText(CONCAT(
‘(‘
, @lon — 10 / ( 111.1 / cos(RADIANS(@lon)))
, ‘ ‘
, @lat — 10 / 111.1
, ‘,’
, @lon — 10 / ( 111.1 / cos(RADIANS(@lat)))
, ‘ ‘
, @lat — 10 / 111.1
, ‘)’ )
,mypoint) - 65,535 bytes
- 64 bytes
- 255 bytes
- 256 bytes
- SET @sql = CONCAT(‘SELECT ‘, (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), ‘old_salary’) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ’employee’ AND TABLE_SCHEMA = ‘factory’), ‘ FROM employee’);
PREPARE stmt1 FROM @sql;
EXECUTE stmt1; - Use DESCRIBE and with the results another SELECT query can be generated.
- Select all the other columns from the ’employee’ table except the ‘old_salary’ column.
- SELECT * FROM employee;
- ADD NEW
- INSERT INTO
- INSERT NEW
- ADD RECORD
- SELECT SUM(TABLE_ROWS)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = ‘{your_db}’; - SELECT TOTAL(TABLE_ROWS)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = ‘{your_db}’; - SELECT COUNT(TABLE_ROWS)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = ‘{your_db}’; - SELECT ROUND(TABLE_ROWS)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = ‘{your_db}’; - SAVE
- MODIFY
- SAVE AS
- UPDATE
- UPDATE table_name SET Col1 = CASE id
WHEN 1 THEN 1
WHEN 2 THEN 2
WHEN 4 THEN 10
ELSE Col1
END,
Col2 = CASE id
WHEN 3 THEN 3
WHEN 4 THEN 12
ELSE Col2
END
WHERE id IN (1, 2, 3, 4); - UPDATE table_name SET Col1 = 1 WHERE id = 1;
UPDATE table_name SET Col1 = 2 WHERE id = 2;
UPDATE table_name SET Col2 = 3 WHERE id = 3;
UPDATE table_name SET Col1 = 10 WHERE id = 4;
UPDATE table_name SET Col2 = 12 WHERE id = 4; - INSERT INTO table_name (id,Col1,Col2) VALUES (1,1,1),(2,2,3),(3,9,3),(4,10,12)
ON DUPLICATE KEY UPDATE Col1=VALUES(Col1),Col2=VALUES(Col2); - UPDATE table_name SET col1 = ‘1’ WHERE id IN (1);
UPDATE table_name SET col1 = ‘2’ WHERE id IN (2);
UPDATE table_name SET col2 = ‘3’ WHERE id IN (3);
UPDATE table_name SET col1 = ’10’, col2=’12’ WHERE id IN (4); - UPDATE table_name SET Col1 = CASE id
WHEN 1 THEN 1
WHEN 2 THEN 2
WHEN 4 THEN 10
ELSE Col1
END,
Col2 = CASE id
WHEN 3 THEN 3
WHEN 4 THEN 12
ELSE Col2
END
WHERE id IN (1, 2, 3, 4); - UPDATE table_name SET Col1 = 1 WHERE id = 1;
UPDATE table_name SET Col1 = 2 WHERE id = 2;
UPDATE table_name SET Col2 = 3 WHERE id = 3;
UPDATE table_name SET Col1 = 10 WHERE id = 4;
UPDATE table_name SET Col2 = 12 WHERE id = 4; - INSERT INTO table_name (id,Col1,Col2) VALUES (1,1,1),(2,2,3),(3,9,3),(4,10,12)
ON DUPLICATE KEY UPDATE Col1=VALUES(Col1),Col2=VALUES(Col2); - UPDATE table_name SET col1 = ‘1’ WHERE id IN (1);
UPDATE table_name SET col1 = ‘2’ WHERE id IN (2);
UPDATE table_name SET col2 = ‘3’ WHERE id IN (3);
UPDATE table_name SET col1 = ’10’, col2=’12’ WHERE id IN (4); - The LENGTH of NULL is NULL.
- NULLs are sorted before empty strings.
- The COUNT() function will count empty strings but not NULLs.
- All of the above.
- SELECT ‘TRUNCATE TABLE ‘ + TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
- SELECT Concat(‘TRUNCATE TABLE ‘, TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES
- SELECT Concat(‘TRUNCATE TABLE ‘, TABLE_NAME, ‘\n’) FROM INFORMATION_SCHEMA.TABLES
- SELECT Concat(‘TRUNCATE TABLE ‘, TABLE_NAME, ‘;’) FROM INFORMATION_SCHEMA.TABLES
- SELECT id,
IF type = ‘P’ THEN amount = amount
ELSE amount = amount — 1
FROM report; - SELECT id,
CASE type
IF ‘P’ THEN amount = amount
IF ‘N’ THEN amount = -amount
END AS amount
FROM report; - SELECT id, IF(type = ‘P’?amount:amount * -1) AS amount
FROM report; - SELECT id, IF(type = ‘P’, amount, amount * -1) AS amount
FROM report; - IS NULL
- =
- LIKE
- <>
- INSERT
- UPDATE
- DELETE
- SELECT
- INFORMATION_SCHEMA
- All the test databases
- mysql database
- All databases with MyISAM tables
- SELECT VERSION()
- SELECT MYSQL_VERSION()
- SELECT —VERSION
- None of the above.
- 256
- 255
- 127
- 128
- SELECT * FROM Customers WHERE LastName BETWEEN ‘Martinez’ AND ‘Smith’
- SELECT LastName>’Martinez’ AND LastName<‘Smith’ FROM Customers • SELECT * FROM Customers WHERE LastName>’Martinez’ AND LastName<‘Smith’
- SELECT Customers WHERE LastName BETWEEN ‘Martinez’ AND ‘Smith’
- SELECT Customers WHERE LastName BETWEEN ‘Martinez’ AND ‘Smith’
- SHOW INDEX ;
- SHOW INDEX FROM ;
- SHOW *INDEX FROM ;
- None of the above.
- BLOB
- FLOAT
- TEXT
- BIT
- 4
- 8
- 3
- 2
- TINYBLOB
- MEDIUMBLOB
- LONGBLOB
- LARGEBLOB
- ALTER EVENT, CREATE EVENT and DROP EVENT
- ALTER SERVER, CREATE SERVER and DROP SERVER
- CREATE DATABASE, DROP DATABASE and ALTER DATABASE
- ANALYZE TABLE, CHECK TABLE, OPTIMIZE TABLE, and REPAIR TABLE
- <>
- >=
- <=
- ^=
- INSERT INTO Customers (LastName) VALUES (‘Smith’)
- INSERT INTO Customers (‘Smith’) INTO LastName
- INSERT (‘Smith’) INTO Customers (LastName)
- INSERT (LastName) VALUES (‘Smith’) INTO Customers
- INSERT (‘John’, ‘Smith’) INTO Customers
- INSERT VALUES (‘John’, ‘Smith’) INTO Customers
- INSERT INTO Customers VALUES (‘John’, ‘Smith’)
- INSERT VALUES (‘John’, ‘Smith’) INTO Customers
- INSERT (‘John’, ‘Smith’) INTO Customers
- INSERT VALUES (‘John’, ‘Smith’) INTO Customers
- INSERT INTO Customers VALUES (‘John’, ‘Smith’)
- INSERT VALUES (‘John’, ‘Smith’) INTO Customers
- UPDATE Customers SET LastName=’Martinez’ INTO LastName=’Smith’
- MODIFY Customers SET LastName=’Smith’ WHERE LastName=’Martinez’
- UPDATE Customers SET LastName=’Smith’ WHERE LastName=’Martinez’
- MODIFY Customers SET LastName=’Martinez’ INTO LastName=’Smith’
- TINYINT
- FLOAT
- LARGEINT
- DOUBLEINT
- DECIMAL
- User variable names are not case sensitive and have a maximum length of 64 characters.
- User variables are written as $var_name, where the variable name var_name consists of alphanumeric characters, “.”, “_”, and “@”.
- User-defined variables are session-specific. A user variable defined by one client cannot be seen or used by other clients.
- 9999.99 to -9999.99
- 9999.99 to -999.99
- 999999.99 to -999999.99
- 999999.99 to -99999.99
- select count(*) is faster in InnoDB than in MyISAM
- both are equal on MyISAM
- select count(*) is faster in MyISAM than in InnoDB
- both are equal on InnoDB
- TINYTEXT
- BLOBTEXT
- MEDIUMTEXT
- LONGTEXT
- GMT_TIME
- DAYOFWEEK
- STR_TO_MONTH
- UTC_DATE
- YEARWEEK
- NVL
- NVL2
- NULLIF
- COALESCE
75. What are MySQL Spatial Data Types in the following list?
Answers:
76. Which of the following statements relating to Alias names is true?
Answers:
77. Examine the description of the STUDENTS table:
Answers:
STD_ID INT
COURSE_ID VARCHAR (10)
START_DATE DATE
END_DATE DATE
The aggregate functions valid on the START_DATE column are:
STD_ID INT
COURSE_ID VARCHAR (10)
START_DATE DATE
END_DATE DATE
The aggregate functions valid on the START_DATE column are:
78. Which of the following is the correct way to change the character set to UTF8?
Answers:
STD_ID INT
COURSE_ID VARCHAR (10)
START_DATE DATE
END_DATE DATE
The aggregate functions valid on the START_DATE column are:
STD_ID INT
COURSE_ID VARCHAR (10)
START_DATE DATE
END_DATE DATE
The aggregate functions valid on the START_DATE column are:
[mysqld]
default-character-set = utf8
78. To quote a string within a string, which of the following can you use?
Answers:
STD_ID INT
COURSE_ID VARCHAR (10)
START_DATE DATE
END_DATE DATE
The aggregate functions valid on the START_DATE column are:
STD_ID INT
COURSE_ID VARCHAR (10)
START_DATE DATE
END_DATE DATE
The aggregate functions valid on the START_DATE column are:
79.SELECT employee_id FROM employees WHERE commission_pct=.5 OR salary > 23000;
Which of the following statements is correct with regard to this code?
Answers:
Which of the following statements is correct with regard to this code?
Answers:
80.Select which of the following is the best way to duplicate MySql Database(DB1) in to another database(DB2) without using mysqldump?
Answers:
81.Which of the following statement will results in 0 (false)?
Answers:
82.Which query will display data from the Pers table relating to Analyst, Clerk and Salesman who joined between 1/1/2005 and 1/2/2005 ?
Answers:
83. How can a InnoDB database be backed up without locking the tables?
Answers:
85. Which of the following is not a valid Bit operator?
Answers:
86. What is the main purpose of InnoDB over MyISAM?
Answers:
87. View the following Create statement:
1. Create table Pers
2. (EmpNo Int not null,
3. EName Char not null,
4. Join_dt Date not null,
5. Pay Int)
Answers:
1. Create table Pers
2. (EmpNo Int not null,
3. EName Char not null,
4. Join_dt Date not null,
5. Pay Int)
Answers:
88.What will happen if some of the columns in a table are of char datatype and others are of varchar datatype?
Answers:
89.If you insert (00) as the value of the year in a date column, what will be stored in the database?
Answers:
90.Which of the following statements is true is regards to whether the schema integration problem between development, test, and production servers can be solved?
Answers:
91. Which of the following is not a valid Logical operator?
Answers:
92. What is true regarding the TIMESTAMP data type?
Answers:
93. Which of the following is not a SQL operator?
Answers:
94. Which of the following is not a SQL operator?
Answers:
95.Which of the following is not a valid Comparison operator?
Answers:
96.What will happen if you write the following statement on the MySQL prompt?
SELECT NOW();
SELECT NOW();
Answers:
97.Assuming the column col1 in table tab1 has the following values:
2,3,NULL,2,3,1
What will be the output of the select statement below?
SELECT count(col1) FROM tab1
2,3,NULL,2,3,1
What will be the output of the select statement below?
SELECT count(col1) FROM tab1
Answers:
98. What is the correct SQL syntax for selecting all the columns from the table Persons where the LastName is alphabetically between (and including) «Hansen» and «Pettersen»?
CREATE TABLE `Persons` (
`LastName` varchar(244) NOT NULL DEFAULT »
) ENGINE=InnoDB;
REPLACE INTO Persons VALUE (‘Hansen’),(‘Pettersen’),(‘Nilsen’),(‘Smith’);
CREATE TABLE `Persons` (
`LastName` varchar(244) NOT NULL DEFAULT »
) ENGINE=InnoDB;
REPLACE INTO Persons VALUE (‘Hansen’),(‘Pettersen’),(‘Nilsen’),(‘Smith’);
Answers:
99.Which of the following statements is correct in regards to the syntax of the code below?
SELECT table1.this, table2.that, table2.somethingelse
FROM table1
INNER JOIN table2 ON table1.foreignkey = table2.primarykey
WHERE (some other conditions)
SELECT table1.this, table2.that, table2.somethingelse
FROM table1
INNER JOIN table2 ON table1.foreignkey = table2.primarykey
WHERE (some other conditions)
Answers:
100.Considering table foo has been created with:create table foo (id int primary key auto_increment, name varchar(100));
Is the following query syntactically valid?
delete from foo where id = id-1;
Is the following query syntactically valid?
delete from foo where id = id-1;
Answers:
101.The STUDENT_GRADES table has these columns:
STUDENT_ID INT
SEMESTER_END DATE
GPA FLOAT
STUDENT_ID INT
SEMESTER_END DATE
GPA FLOAT
Which of the following statements finds the highest Grade Point Average (GPA) per semester?
Answers:
Answers:
102.Which of the following queries is valid?
Answers:
Answers:
103.Which of the following are aggregate functions in MySQL?
Answers:
Answers:
104. Which of the following statements are true?
Answers:
Answers:
105.You are maintaining data for a Products table, and want to see the products which have a currentstock of at least 50 more than the minimum stock limit.
The structure of the Products table is:
The structure of the Products table is:
ProductID
ProductName
CurrentStock
MinimumStock
Two possible queries are:
a)select * from products where currentStock > MinimumStock + 50
(b)select * from products where currentStock — 50 > MinimumStock
Choose the appropriate option with regard to the above queries.
Answers:
ProductName
CurrentStock
MinimumStock
Two possible queries are:
a)select * from products where currentStock > MinimumStock + 50
(b)select * from products where currentStock — 50 > MinimumStock
Choose the appropriate option with regard to the above queries.
Answers:
106. Which operator will be evaluated first in the following statement:
select (age + 3 * 4 / 2 ? 8) from emp
Answers:
select (age + 3 * 4 / 2 ? 8) from emp
Answers:
107. Is the following query valid?
create table foo (id int primary key auto_increment, name varchar);
Answers:
create table foo (id int primary key auto_increment, name varchar);
Answers:
108. What is the difference between the following commands? Command D: DELETE from customers; Command T: TRUCATE table customers;
Answers:
Answers:
109.What kind of joins does MySQL support?
Answers:
Answers:
110. Why is the following GRANT statement considered a bad security practice:
GRANT ALL PRIVILEGES ON db_test.* TO ‘john’@’%’ IDENTIFIED BY ‘0!Nh6l7tEjohn’
Answers:
GRANT ALL PRIVILEGES ON db_test.* TO ‘john’@’%’ IDENTIFIED BY ‘0!Nh6l7tEjohn’
Answers:
111. What is wrong with the following query:
select * from Orders where OrderID = (select OrderID from OrderItems where ItemQty > 50)
Answers:
select * from Orders where OrderID = (select OrderID from OrderItems where ItemQty > 50)
Answers:
112. Which approach can be used to find all occurrences of text “owner” in all fields of all tables in a MySQL database?
Answers:
Answers:
113. What is true regarding the SET data type?
Answers:
Answers:
114. What is the correct order of clauses in the select statement?
1 select
2 order by
3 where
4 having
5 group by
1 select
2 order by
3 where
4 having
5 group by
Answers:
115. Consider the table employees with fields name and surname (nulls allowed in both fields) having following data:
nsert into employees (name,surname) values (‘John’, ‘Smith’);
insert into employees (name,surname) values (‘Peter’, NULL);
insert into employees (name,surname) values (NULL, ‘Brown’);
nsert into employees (name,surname) values (‘John’, ‘Smith’);
insert into employees (name,surname) values (‘Peter’, NULL);
insert into employees (name,surname) values (NULL, ‘Brown’);
What will be the output of the following query:
select CONCAT( name, ‘ ‘, COALESCE( surname,» ) ) FROM employees;
select CONCAT( name, ‘ ‘, COALESCE( surname,» ) ) FROM employees;
Answers:
116. Consider the table employees with fields name and surname (nulls allowed in both fields) having following data:
nsert into employees (name,surname) values (‘John’, ‘Smith’);
insert into employees (name,surname) values (‘Peter’, NULL);
insert into employees (name,surname) values (NULL, ‘Brown’);
nsert into employees (name,surname) values (‘John’, ‘Smith’);
insert into employees (name,surname) values (‘Peter’, NULL);
insert into employees (name,surname) values (NULL, ‘Brown’);
117. How could the following sql query be rewritten?
SELECT name, location FROM `venues` WHERE id IN ( SELECT venue_id FROM `events` );
SELECT name, location FROM `venues` WHERE id IN ( SELECT venue_id FROM `events` );
Answers:
118. Which command lists stored procedures in mysql?
SELECT name, location FROM `venues` WHERE id IN ( SELECT venue_id FROM `events` );
SELECT name, location FROM `venues` WHERE id IN ( SELECT venue_id FROM `events` );
Answers:
119. Which of the following operators has the highest precedence?
Answers:
Answers:
120. Which of the following is a valid declaration?
Answers:
Answers:
121.The next MySQL database has one table called people_hobbies which has who columns: person_id and hobbies. Which statement should be used to concatenate multiple hobbies into one single field?
Answers:
Answers:
122.The next MySQL database has one table called people_hobbies which has who columns: person_id and hobbies. Which statement should be used to concatenate multiple hobbies into one single field?
Answers:
Answers:
123.Consider the following table
CREATE TABLE `foo` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`u` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `u` (`u`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`u` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `u` (`u`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
mysql> select * from foo;
+—-+——+
| id | u |
+—-+——+
| 1 | 10 |
+—-+——+
+—-+——+
| id | u |
+—-+——+
| 1 | 10 |
+—-+——+
What is output for «select * from foo ;» command after executed following SQL command ?
replace into foo (u) values (20);
replace into foo (u) values (20);
Answers:
124. Which function is used to get the higher of two values, a and b, in MySQL?
Answers:
Answers:
125. Evaluate the following SQL statement:
SELECT e.employee_id, (.15* e.salary) + (.5 * e.commission_pct) + (s.sales_amount * (.35 * e.bonus)) AS CALC_VALUE FROM employees e, sales s WHERE e.employee_id = s.emp_id;
SELECT e.employee_id, (.15* e.salary) + (.5 * e.commission_pct) + (s.sales_amount * (.35 * e.bonus)) AS CALC_VALUE FROM employees e, sales s WHERE e.employee_id = s.emp_id;
What will happen if all the parentheses are removed from the calculation?
Answers:
Answers:
126. Which of the following queries will find all constraints that reference the field ID of table APPLICATIONS in database PROD_DB?
Answers:
Answers:
127. What is the correct syntax for updating a table using LEFT OUTER JOIN?
Answers:
Answers:
128. Which of the following statements are true regarding recovering MySQL DBs from .myd, .myi, and .frm files?
Answers:
Answers:
129. What will happen if you query the emp table as shown below:
select empno, DISTINCT ename, Salary from emp;
Answers:
select empno, DISTINCT ename, Salary from emp;
Answers:
130. Many people use MySql statements as : —
Select * from car_table where 1=1 and value=”TOYOTA”
Exactly what does (where 1=1 and value=”TOYOTA”) mean here?
Answers:
Select * from car_table where 1=1 and value=”TOYOTA”
Exactly what does (where 1=1 and value=”TOYOTA”) mean here?
Answers:
131. Is it possible to use group by clause to concatenate strings?
Answers:
Answers:
132. Which of the following statements is correct?
Answers:
Answers:
133. DELETE FROM story_category WHERE category_id NOT IN (
SELECT DISTINCT category.id FROM category INNER JOIN story_category ON category_id=category.id);
Which of the following is a possible reason why this statement is showing an error?
SELECT DISTINCT category.id FROM category INNER JOIN story_category ON category_id=category.id);
Which of the following is a possible reason why this statement is showing an error?
Answers:
134. Which datatype is recommended for storing SHA-1 hash values?
Answers:
135. What is the difference between INSERT INTO table VALUES & INSERT INTO table SET in MySQL?
Answers:
136. How can the following error be solved in MySQL?
ERROR 1153: Got a packet bigger than ‘max_allowed_packet’ bytes
ERROR 1153: Got a packet bigger than ‘max_allowed_packet’ bytes
Answers:
137. What is the most common use of the mysql EXPLAIN statement?
Answers:
138. Which is the correct query to find out the number of ENUM(‘M’, ‘F’, ‘NA’) datatypes columns that exist in all databases?
Answers:
139. Which of the following will join the same table twice?
Answers:
140. How can a default value be set for a MySQL Datetime column?
Answers:
141. The CAST() function does not support cast to which of the following data types?
Answers:
142. What value return “type” column in EXPLAIN plans for a full table scan of select query?
Answers:
143. Which SQL statement is used to extract data from a database?
Answers:
144. How can database versioning be achieved in MySQL?
Answers:
145. Consider the queries mentioned below:
Query 1:
SELECT ‘id’, ‘name’, ‘anotherfield’ …
Query 2:
SELECT id, name, anotherfield …
Which of the following is true regarding the results of these queries?
Answers:
Query 1:
SELECT ‘id’, ‘name’, ‘anotherfield’ …
Query 2:
SELECT id, name, anotherfield …
Which of the following is true regarding the results of these queries?
Answers:
146. For a table called PEOPLE with the following columns:
ID, NAME, GENDER, AGE, PHONE, EMAIL
ID, NAME, GENDER, AGE, PHONE, EMAIL
ID is integer and PRIMARY KEY,
NAME is varchar,
GENDER is varchar,
AGE is integer,
PHONE is integer,
EMAIL is varchar
What happens if the following query is executed?
SELECT * FROM PEOPLE ORDER BY _rowid DESC;
Answers:
NAME is varchar,
GENDER is varchar,
AGE is integer,
PHONE is integer,
EMAIL is varchar
What happens if the following query is executed?
SELECT * FROM PEOPLE ORDER BY _rowid DESC;
Answers:
147. What is the max number of connections allowed by default in MySQL 5.0?
Answers:
148. Which of the following will reclaim unused space in all databases of a MySQL server instance?
Answers:
149. table votes (
id,
user,
email,
address,
primary key(id),
);
id,
user,
email,
address,
primary key(id),
);
Which of the following is the correct code to change the columns (user, email, address) as UNIQUE KEY in MySQL?
Answers:
150. Which of the following is correct syntax for selecting all rows from a table ‘PERSONS’, with strings in the column ‘LASTNAME’ starting with ‘JOH’?
Answers:
151. Which of the following statements is true regarding the WHERE and HAVING clauses in MySQL?
Answers:
152. Which data type is recommended to be used in MySQL when the date value must be converted from the current time zone to Coordinated Universal Time (UTC) for storage, and converted back from Coordinated Universal Time (UTC) to the current time zone for retrieval?
Answers:
153. With SQL, how do you select all the records from a table named “Customers” where the value of the column “FirstName” starts with an “b”?
Answers:
154. Which of the following is the correct datatype to store a bcrypt hash password?
Answers:
155. A MySQL database has a table named APPLICATIONS with a column named TITLE. The goal is to randomly select 10 applications and allow web site users a 20% discount on buying these applications. Which query can be used to obtain the list of titles of applications to be included in the list?
Answers:
156. Which of the following is the best data type for a field that will hold a URL with an undetermined length?
Answers:
157 .Which of the following are ways to detect changes in a MySQL database schema?
Answers:
158 .Which of the following are ways to detect changes in a MySQL database schema?
Answers:
159. Which of the following statements is incorrect?
Answers:
160. Which of the following are valid encryption functions?
Answers:
161. What are the Privileges required if the read_only system variable is enabled, to explicitly start a transaction with START TRANSACTION READ WRITE?
Answers:
162. With which of the following you can not associate a Trigger?
Answers:
163. What is the default maximum number of indexes per MyISAM table?
Answers:
164. Which variable can be modified to change the maximum size of a heap table?
Answers:
165. What is the default maximum number of columns per index in MyISAM?
Answers:
166. Let’s say that you have a very large table “users” with an index on the column “age”. How would you most efficiently select all the first names of users that are between 15 and 24 years old?
Answers:
167. How would you return a random nickname from a very large “users” table?
Answers:
168. How do you set execution timeout for SELECT statements in MySQL?
Answers:
169. Which database provides a standards-compliant means for accessing the MySQL Server’s metadata?
Answers:
170. Which MySQL function is used to measure the speed of a specific MySQL expression or function?
Answers:
171. Which storage engine in MySQL supports Transactions?
Answers:
172. Which of the following Storage Engines in MySQL supports Foreign Keys?
Answers:
173. Which storage engine in MySQL supports Transactions?
Answers:
174. What is the default TCP/IP port on which the MySQL server listens for connections?
Answers:
175. Which of the following are the new storage engines added in MySQL 5.0?
Answers:
176. What is the output when the following query executes?
CREATE TABLE t2 (val INT)
PARTITION BY LIST(val)(
PARTITION mypart VALUES IN (1,3,5),
PARTITION MyPart VALUES IN (2,4,6)
);
CREATE TABLE t2 (val INT)
PARTITION BY LIST(val)(
PARTITION mypart VALUES IN (1,3,5),
PARTITION MyPart VALUES IN (2,4,6)
);
Answers:
177. What is the output when the following query executes?
CREATE TABLE t2 (val INT)
PARTITION BY LIST(val)(
PARTITION mypart VALUES IN (1,3,5),
PARTITION MyPart VALUES IN (2,4,6)
);
CREATE TABLE t2 (val INT)
PARTITION BY LIST(val)(
PARTITION mypart VALUES IN (1,3,5),
PARTITION MyPart VALUES IN (2,4,6)
);
Answers:
178. Which command would allow SELECT statements to be executed on a MySQL database without causing locks??
Answers:
179. Consider the following Table
EMP:
—————
empId
empName
empSalary
empJoinDate
Which SQL is incorrect for finding out the count of records on EMP table where empJoinDate is between 2012-10-01 and 2012-12-30?
EMP:
—————
empId
empName
empSalary
empJoinDate
Which SQL is incorrect for finding out the count of records on EMP table where empJoinDate is between 2012-10-01 and 2012-12-30?
Answers:
180. Which of the following is not a valid Trigger?
Answers:
181. ENUM column can have a maximum of ____ distinct elements.
Answers:
182. Which statement is used to disable autocommit mode implicitly for a single series of statements?
Answers:
183. Which «MySQL» client utility option is useful for MySQL query execution on the command line?
Answers:
184. How many Auto Increment columns can be present per table in MySQL?
Answers:
185. What happens when the column is set to AUTO INCREMENT and if you reach maximum value in the table?
Answers:
186. Which of the following statements is true?
Answers:
187. Based on performance, which of the following is the quickest way to select a random row from a large table in MySQL?
Answers:
SELECT * FROM `table` WHERE id >= (SELECT FLOOR( MAX(id) * RAND()) FROM `table` ) ORDER BY id LIMIT 1
188. Full-text indexes can be used only with tables of which of the following Storage Engines?
Answers:
189. Which of the following is not a valid MyISAM table format?
Answers:
190. MyISAM tables can have three different storage formats: static (fixed-length), dynamic or compressed. Which of the following statements are true for the static format?
Answers:
191. What is the maximum length of a VARCHAR column?
Answers:
192. What is the maximum length of a VARCHAR column?
Answers:
193. Which of the following is not a valid statement?
Answers:
194. A system that uses a MySQL database has around 500,000 daily visitors. There is a requirement to record these visitors (IP address and timestamp). Which is the most effective solution performance-wise?
Answers:
195. Is there any function in MySQL that allows for replace through a regular expression?
Answers:
196. Consider a list of date ranges (range-start and range-end):
10/06/1983 to 14/06/1983
15/07/1983 to 16/07/1983
18/07/1983 to 19/07/1983
10/06/1983 to 14/06/1983
15/07/1983 to 16/07/1983
18/07/1983 to 19/07/1983
What will be the best way to find out if another date range containing any of the ranges already exists in the above list?
Answers:
Answers:
197. Which of the following will find the distance between two pairs of latitude and longitude points?
10/06/1983 to 14/06/1983
15/07/1983 to 16/07/1983
18/07/1983 to 19/07/1983
10/06/1983 to 14/06/1983
15/07/1983 to 16/07/1983
18/07/1983 to 19/07/1983
What will be the best way to find out if another date range containing any of the ranges already exists in the above list?
Answers:
Answers:
198. What is the effective maximum length of a VARCHAR column?
Answers:
199. What is the best way to select all the columns from the ’employee’ table except one column, ‘old_salary’, in the ‘factory’ database?
Answers:
200. Which SQL statement is used to insert new data in a database?
Answers:
201.Which of the following will get the record count for all tables in a MySQL database?
Answers:
202. Which SQL statement is used to update data in a database?
Answers:
203. Which of the following is the best way to update multiple rows?
Example:
Name id Col1 Col2
name1 1 6 1
name2 2 2 3
name3 3 9 5
name4 4 16 8
Example:
Name id Col1 Col2
name1 1 6 1
name2 2 2 3
name3 3 9 5
name4 4 16 8
Update Col1= 1 where id = 1
Update Col1= 2 where id = 2
Update Col2= 3 where id = 3
Update Col1= 10 and col2= 12 where id = 4
Update Col1= 2 where id = 2
Update Col2= 3 where id = 3
Update Col1= 10 and col2= 12 where id = 4
Answers:
204. Which of the following is the best way to update multiple rows?
Example:
Name id Col1 Col2
name1 1 6 1
name2 2 2 3
name3 3 9 5
name4 4 16 8
Example:
Name id Col1 Col2
name1 1 6 1
name2 2 2 3
name3 3 9 5
name4 4 16 8
Update Col1= 1 where id = 1
Update Col1= 2 where id = 2
Update Col2= 3 where id = 3
Update Col1= 10 and col2= 12 where id = 4
Update Col1= 2 where id = 2
Update Col2= 3 where id = 3
Update Col1= 10 and col2= 12 where id = 4
Answers:
205. Which among the following statements are true about using «NULL» in database columns?
Answers:
206. Which of the following will truncate all tables in a MySQL database?
Answers:
207. A table called report has three columns: id, type and amount. From this table two columns must be selected: id and amount. If type is ‘P’, then amount has be amount and if type is ‘N’, then amount has to be -amount. What is the best way to select those two columns?
Answers:
208. Which of the following can be used to check if a column in a row of a table is NULL?
Answers:
209. InnoDB prevents which of the following operations when innodb_force_recovery is greater than 0?
Answers:
210. Which database is ignored by ‘mysqldump’ while dumping a collection of databases for backup?
Answers:
211. How do you print the version of MySQL server?
Answers:
212. What is the maximum value of an unsigned TINYINT integer type?
Answers:
213. With SQL, how do you select all the records from a table named «Customers» where the «LastName» is alphabetically between (and including) «Martinez» and «Smith»?
Answers:
214. How can you see all indexes defined for a table?
Answers:
215. Heap tables support which of the following data types?
Answers:
216. How many bytes of storage does the BIGINT integer type requires?
Answers:
217. Which of the following is not a valid BLOB type?
Answers:
218. MySQL supports some extensions that you probably cannot find in other SQL DBMs. Which SQL statements are part of these extensions?
Answers:
219. Which of the following is not a valid comparison operator?
Answers:
220. With SQL, how can you insert «Smith» as the «LastName» in the «Customers» table?
Answers:
221. With SQL, how can you insert a new record into the «Customers» table?
Answers:
222. With SQL, how can you insert a new record into the «Customers» table?
Answers:
223. How can you change «Martinez» into «Smith» in the «LastName» column in the Customers table?
Answers:
224. Select valid numeric data types:
Answers:
225. Which of the statements are true for user-defined variables?
Answers:
226. What is the range of the values that can go in a column defined as DECIMAl(6,2) ?
Answers:
227. Is select count(*) faster than select count(identifier) ?
Answers:
228. Which of the following is not a valid nonstandard string types?
Answers:
229. Select valid date and time functions in MySQL:
Answers:
230. For some particular assignment , you need to compare two values, if both are equal, the result would be null, and if the value are not equal then the first value should be returned. Which function should you use?
Answers: