0% found this document useful (0 votes)
73 views17 pages

Linkedin-Skill-Assessments-Quizzes - Mysql - Mysql-Quiz - MD at Main Ebazhanov - Linkedin-Skill-Assessments-Quizzes GitHub

The document discusses a MySQL quiz with 30 multiple choice questions about MySQL concepts and syntax. Some of the topics covered include subqueries, exporting databases with mysqldump, column constraints, creating stored procedures, data types for storing grades, creating tables with primary keys, joining tables, filtering queries, and administering a MySQL server.

Uploaded by

sakhr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views17 pages

Linkedin-Skill-Assessments-Quizzes - Mysql - Mysql-Quiz - MD at Main Ebazhanov - Linkedin-Skill-Assessments-Quizzes GitHub

The document discusses a MySQL quiz with 30 multiple choice questions about MySQL concepts and syntax. Some of the topics covered include subqueries, exporting databases with mysqldump, column constraints, creating stored procedures, data types for storing grades, creating tables with primary keys, joining tables, filtering queries, and administering a MySQL server.

Uploaded by

sakhr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Ebazhanov / linkedin-skill-assessments-quizzes Public

Code Issues 89 Pull requests

main linkedin-skill-assessments-quizzes / mysql / mysql-quiz.md Go to file

Ebazhanov and actions-user Prettified Code! 6 months ago

Executable File · 1201 lines (857 loc) · 39.2 KB

Preview Code Blame Raw

1 ## MySQL
2
3 #### Q1. When you have a subquery inside of the main query, which query is executed first?
4
5 - [ ] The subquery is never executed. Only the main query is executed.
6 - [ ] They are executed at the same time
7 - [ ] the main query
8 - [x] the subquery
9
10 #### Q2. You need to export the entire database, including the database objects, in addition to the data. Which command-line tool do you
11
12 - [ ] mysqlexport
13 - [ ] mysqladmin
14 - [x] mysqldump
15 - [ ] mysqld
16
17 #### Q3. You must ensure the accuracy and reliability of the data in your database. You assign some constraints to limit the type of data
18
19 - [ ] row level
20 - [ ] database level
21 - [x] column level
22 - [ ] function level
23
24 #### Q4. Which option of most MySQL command-line programs can be used to get a description of the program's different options?
25
26 - [ ] --options
27 - [ ] ?
28 - [x] --help
29 - [ ] -h
30
31 #### Q5. MySQL uses environment variables in some of the programs and command-line operations. Which variable is used by the shell to fin
32
33 - [ ] DIR
34 - [ ] HOME
35 - [x] PATH
36 - [ ] MYSQL_HOME
37
38 #### Q6. How can you create a stored procedure in MySQL?
39
40 - [ ] A
41
42 ```
43 1 CREATE PROCEDURE P () AS
44 2 BEGIN
45 3 END;
46 ```
47
48 - [x] B
49
50 ```
51 1 CREATE PROCEDURE P ()
52 2 BEGIN
53 3 END
54 ```
55
56 - [ ] C
57
58 ```
59 1 CREATE PROCP
60 2 BEGIN
61 3 END;
62 ```
63
64 - [ ] D
65
66 ```
67 1 CREATE PROC P AS O
68 2 BEGIN
69 3 END;
70 ```
71
72 #### Q7. If you were building a table schema to store student grades as a letter (A, B, C, D, or F) which column type would be the best c
73
74 - [x] ENUM
75 - [ ] OTEXT
76 - [ ] VARCHAR
77 - [ ] LONGTEXT
78
79 #### Q8. Management has requested that you build an employee database. You start with the employee table. What is the correct syntax?
80
81 - [ ] A
82
83 ```sql
84 CREATE TABLE employee (
85 employeeID char(10),
86 firstName varchar(50),
87 lastName varchar(50),
88 phone varchar(20),
89 address varchar(50),
90 PRIMARY KEY ON employeeID
91 );
92 ```
93
94 - [ ] B
95
96 ```sql
97 CREATE TABLE employee (
98 employeeID char(10),
99 firstName varchar(50),
100 lastName varchar(50),
101 phone varchar(20),
102 address varchar(50),
103 PRIMARY KEY employeeID
104 );
105 ```
106
107 - [ ] C
108
109 ```sql
110 CREATE TABLE IF EXISTS employee (
111 employeeID char(10),
112 firstName varchar(50),
113 lastName varchar(50),
114 phone varchar(20),
115 address varchar(50),
116 PRIMARY KEY (employeeID)
117 );
118 ```
119
120 - [x] D
121
122 ```sql
123 CREATE TABLE IF NOT EXISTS employee (
124 employeeID char(10),
125 firstName varchar(50),
126 lastName varchar(50),
127 phone varchar(20),
128 address varchar(50),
129 PRIMARY KEY (employeeID)
130 );
131 ```
131
132
133 #### Q9. You are working with the tables as shown in this diagram. You need to generate the list of customers who purchased certain car m
134
135 ![mysql Q09](images/mysql_q09.jpg?raw=true)
136
137 - [ ] LIKE
138 - [x] IN
139 - [ ] BETWEEN
140 - [ ] HAVING
141
142 #### Q10. Which query would NOT be used to administer a MySQL server?
143
144 - [ ] USE db
145 - [x] SELECT column FROM tbl
146 - [ ] SHOW COLUMNS FROM tbl
147 - [ ] SHOW TABLES
148
149 #### Q11. MySQL server can operate in different SQL modes, depending on the value of the sql_mode system variable. Which mode changes syn
150
151 - [ ] TRADITIONAL
152 - [x] ANSI
153 - [ ] MSSQL
154 - [ ] STRICT
155
156 #### Q12. MySQL programs are a set of command-line utilities that are provided with typical MySQL distributions. MySQL is designed to be
157
158 - [ ] database and programming
159 - [ ] user and administrator
160 - [x] client and server
161 - [ ] syntax and objects
162
163 #### Q13. Which MySQL command shows the structure of a table?
164
165 - [ ] INFO table;
166 - [ ] SHOW table;
167 - [ ] STRUCTURE table;
168 - [x] DESCRIBE table;
169
170 #### Q14. MySQL uses security based on \_ for all connections, queries, and other operations that users can attempt to perform. or How ar
171
172 - [ ] administrator schema
173 - [ ] encrypted algorithms
174 - [ ] user settings
175 - [x] access control lists
176
177 [Reference](https://dev.mysql.com/doc/refman/8.0/en/security-guidelines.html)
178
179 #### Q15. Which MySQL command modifies data records in a table?
180
181 - [x] UPDATE
182 - [ ] MODIFY
183 - [ ] CHANGE
184 - [ ] ALTER
185
186 #### Q16. What is the best type of query for validating the format of an email address in a MySQL table?
187
188 - [ ] a SQL query using partitions
189 - [ ] a SQL query using IS NULL
190 - [x] a SQL query using a regular expression
191 - [ ] a SQL query using LTRIM Or RTRIM
192
193 #### Q17. In MySQL, queries are always followed by what character?
194
195 - [ ] line break
196 - [ ] colon
197 - [x] semicolon
198 - [ ] period
199
200 #### Q18. How can you remove a record using MySQL?
201
202 - [ ] DELETE
203 - [x] DELETE FROM
204 - [ ] REMOVE
205 - [ ] REMOVE FROM
206
207 #### Q19. Which choice is NOT a statement you would use to filter data?
208
209 - [x] GROUP BY
210 - [ ] WHERE
211 - [ ] LIMIT
212 - [ ] LIKE
213
214 #### Q20. What does the following SQL statement return?
215
216 `SELECT * FROM Employees WHERE EmployeeName LIKE 'a%'`
217
218 - [ ] It records in the Employees table where the value in the EmployeeName column doesn't have an "a".
219 - [x] It records in the Employees table where the value in the EmployeeName column starts with "a".
220 - [ ] It records in the Employees table where the value in the EmployeeName column has an "a".
221 - [ ] It records in the Employees table where the value in the EmployeeName column ends with "a".
222
223 #### Q21. In `SELECT * FROM clients;` what does clients represent?
224
225 - [ ] a SQL query
226 - [ ] a SQL statement
227 - [ ] a database
228 - [x] a table
229
230 #### Q22. How does MySQL differ from SQL?
231
232 - [ ] SQL is a standard language for retrieving and manipulating data from structured databases. MySQL is a nonrelational database manage
233 - [x] SQL is a standard language for retrieving and manipulating data from structured databases. MySQL is a relational database managemen
234 - [ ] They are not different. MySQL and SQL refer to the same thing.
235 - [ ] My SQL is a language, and SQL is a software application.
236
237 #### Q23. If you need to order a table of movies by name, which query will work?
238
239 - [ ] SELECT \* FROM movies GROUP BY name
240 - [x] SELECT \* FROM movies ORDER BY name
241 - [ ] SELECT \* FROM movies ORDER TABLE by name
242 - [ ] SELECT \* FROM movies FILTER BY name
243
244 #### Q24. A trigger is a database object that is associated with a table, and that activates when a particular event occurs for the table
245
246 - [x] INSERT, UPDATE, DELETE
247 - [ ] CREATE, ALTER, DROP
248 - [ ] OPEN, FETCH, CLOSE
249 - [ ] DECLARE, SET, SELECT
250
251 [Reference](https://dev.mysql.com/doc/refman/5.7/en/triggers.html)
252
253 #### Q25. You are working with very large tables in your database. Which SQL clause do you use to prevent exceedingly large query results
254
255 - [ ] UNIQUE
256 - [x] LIMIT
257 - [ ] DISTINCT
258 - [ ] CONSTRAINT
259
260 #### Q26. What is the default port for MySQL Server?
261
262 - [ ] 25
263 - [ ] 990
264 - [ ] 0
265 - [x] 3306
266
267 #### Q27. How can you filter duplicate data while retrieving records from a table?
268
269 - [x] DISTINCT
270 - [ ] WHERE
271 - [ ] LIMIT
272 - [ ] AS
273
274 #### Q28. What is the difference between DROP and TRUNCATE?
275
276 - [ ] They both refer to the same operation of deleting the table completely.
277 - [ ] They both refer to the same operation of clearing the table, but keeping its definition intact.
278 [ ] TRUNCATE deletes table completely removing its definition as well DROP clears the table but does not delete the definition
278 - [ ] TRUNCATE deletes table completely, removing its definition as well. DROP clears the table but does not delete the definition.
279 - [x] DROP deletes table completely, removing its definition as well. TRUNCATE clears the table but does not delete the definition.
280
281 #### Q29. How do you select every row in a given table named "inventory"?
282
283 - [ ] SELECT all FROM inventory;
284 - [ ] FROM inventory SELECT all;
285 - [ ] FROM inventory SELECT \*;
286 - [x] SELECT \* FROM inventory;
287
288 #### Q30. In an efficiently designed relational database, what does every table have?
289
290 - [ ] set of triggers
291 - [ ] sequential id field
292 - [ ] minimum of three columns
293 - [x] primary key
294
295 #### Q31. MySQL option files provide a way to specify commonly used options so that they need not be entered on the command line each tim
296
297 - [ ] variable settings
298 - [x] configuration files
299 - [ ] help files
300 - [ ] default settings
301
302 [Reference](https://dev.mysql.com/doc/refman/8.0/en/option-files.html)
303
304 #### Q32. After installing MySQL, it may be necessary to initialize the \_ which may be done automatically with some MySQL installation m
305
306 - [ ] storage engine
307 - [ ] user accounts
308 - [ ] grant tables
309 - [x] data directory
310
311 #### Q33. You need to export the data in the customers table into a CSV file, with columns headers in the first row. Which clause do you
312
313 - [ ] JOIN
314 - [ ] WITH HEADERS
315 - [x] UNION
316 - [ ] WITH COLUMNS
317
318 [Sample](https://stackoverflow.com/questions/5941809/include-headers-when-using-select-into-outfile)
319
320 #### Q34. One form of backup, replication, enables you to maintain identical data on multiple servers, as a \_ configuration.
321
322 - [ ] remote-local
323 - [ ] parent-child
324 - [x] master-slave
325 - [ ] logical-physical
326
327 #### Q35. What is the requirement for using a subquery in the SELECT clause?
328
329 - [ ] the subquery must use an aggregate function.
330 - [ ] the subquery must refer to the same table as the main query.
331 - [x] the subquery must return a single value.
332 - [ ] the subquery must return at least one value.
333
334 #### Q36. Each time MySQL is upgraded, it is best to execute mysql_upgrade, which looks for incompatibilities with the upgraded MySQL ser
335
336 - [x] it performs a table check and, if problems are found, attempts a table repair.
337 - [ ] it stops and notifies the server administrator that the upgrade cannot complete until the incompatibility issue are resolved.
338 - [ ] it provides a full report of the table specifications and the incompatibilities to the server administrator.
339 - [ ] it performs a table check and, if problems are found, displays the information for the server administrator to take action.
340
341 #### Q37. What mysql statement is used to check which accounts have specific privileges?
342
343 - [x] show grants (displays the privileges and roles that are assigned to a MySQL user account or role)
344 - [ ] show privileges (shows the list of system privileges that the MySQL server supports)
345 - [ ] show access
346 - [ ] show user permissions
347
348 #### Q38. What cannot have a trigger associated with it?
349
350 - [x] temporary table
351 - [ ] system table
352 - [ ] large table
353 - [ ] new table
354
355 [Reference](https://dev.mysql.com/doc/refman/5.7/en/create-trigger.html)
356
357 #### Q39. later versions of mysql support the native json data type for storing json documents. What is a drawback of json columns?
358
359 - [ ] inefficient for storing json documents
360 - [x] cannot be indexed directly
361 - [ ] documents cannot be validated when stored in json columns
362 - [ ] cannot be normalized
363
364 #### Q40. Which statement is true for the diagram below
365
366 ![mysql Q41](images/mysql_q41.jpg?raw=true)
367
368 - [ ] carid is the primary key for purchases
369 - [ ] carid is the foreign key for cars.carid
370 - [x] customerid is the foreign key for customers.id
371 - [ ] customerid is the primary key for purchases
372
373 #### Q41. Which statement can you use to load data from a file into the table?
374
375 - [ ] `cat file | mysql`
376 - [x] `LOAD DATA INFILE`
377 - [ ] `LOAD DATA LOCAL INFILE`
378 - [ ] `extended INSERT statement`
379
380 #### Q43. Which is the correct syntax of an extended insert statement?
381
382 - [ ] insert into cars (make, model, year) values ('Ford', 'Mustang', 2002)
383 ('Mercedes', 'C', 2003)
384
385 - [ ] insert into cars (make, model, year) values ('Ford', 'Mustang', 2002)
386 values ('Mercedes', 'C', 2003)
387
388 - [ ] insert into cars (make, model, year) extended ('Ford', 'Mustang', 2002),
389 ('Mercedes', 'C', 2003)
390
391 - [x] insert into cars (make, model, year) values ('Ford', 'Mustang', 2002),
392 ('Mercedes', 'C', 2003)
393
394 #### Q44. You need to make an exact copy of a table, with all columns and indexes. How can you get all of the information needed to accom
395
396 - [ ] create table
397 - [ ] clone table
398 - [ ] insert into
399 - [x] show create table
400
401 Note that the question is about _getting_ the data and not about the _duplicating_ operation itself. And actually there is no need to run
402
403 #### Q45. you need to make your mysql system secure against attackers. What are you _not_ supposed to do?
404
405 - [ ] Run MySQL server as a normal user.
406 - [ ] Grant PROCESS or SUPER privilege to other users.
407 - [x] Run MySQL server as the unix root user.
408 - [ ] Use the compressed protocol.
409
410 #### Q46. You are managing a database with a table called customers. You created a temporary table also called customers with which you a
411
412 - [ ] `CREATE TEMPORARY TABLE customers;`
413 - [ ] `DROP TEMP TABLE customers;`
414 - [ ] `DROP TABLE customers;`
415 - [x] `DROP TEMPORARY TABLE customers;`
416
417 1. [reference](https://dev.mysql.com/doc/refman/8.0/en/drop-table.html)
418 2. [reference](https://www.mysqltutorial.org/mysql-temporary-table)
419
420 #### Q47. You need to run a complex query with recursive subqueries, but without creating a stored procedure or a function. Which command
421
422 - [ ] COLLATE
423 - [ ] UNION
424 - [ ] FULL JOIN
425 [x] WITH
425 - [x] WITH
426
427 This is exactly what [WITH clause](https://dev.mysql.com/doc/refman/8.0/en/with.html) is designed for
428
429 #### Q48. Which choice is not a processing algorithm for database views?
430
431 - [ ] merge
432 - [x] updatable
433 - [ ] temptable
434 - [ ] undefined
435
436 [Reference](https://dev.mysql.com/doc/refman/8.0/en/view-algorithms.html)
437
438 #### Q49. What is the MySQL `perror` command-line utility used for?
439
440 - [ ] to display your version of MySQL
441 - [ ] to display operating system error codes
442 - [ ] to display default settings that are in error
443 - [x] to display storage error codes
444
445 Note: perror prints a description for a system error code or for a storage engine (table handler) error code -
446 [link](<https://dev.mysql.com/doc/refman/5.7/en/perror.html#:~:text=2%20perror%20%E2%80%94%20Display%20MySQL%20Error%20Message%20Informat
447
448 #### Q50. How can you list all columns for a given table?
449
450 - [ ] SHOW table COLUMNS;
451 - [x] SHOW COLUMNS FROM table;
452 - [ ] LIST table COLUMNS;
453 - [ ] SELECT COLUMNS FROM table;
454
455 Note: `DESCRIBE tablename` is a shortcut for this command
456
457 #### Q51. How would you list the full set of tables in the currently selected database?
458
459 - [ ] SELECT \* FROM DATABASE;
460 - [x] SHOW TABLES;
461 - [ ] LIST TABLES;
462 - [ ] SELECT ALL TABLES;
463
464 #### Q52. Which choice is not one of the table maintenance statements?
465
466 - [ ] CHECK TABLE;
467 - [x] CREATE TABLE;
468 - [ ] ANALYZE TABLE;
469 - [ ] OPTIMIZE TABLE;
470
471 #### Q53. In which table does MySQL store passwords for user accounts?
472
473 - [ ] mysql.accounts;
474 - [ ] mysql.passwords;
475 - [ ] mysql.admin;
476 - [x] mysql.user;
477
478 #### Q54. Management has requested that you build an employee database. You need to include each employee's current position and salary,
479
480 - [ ] primary key;
481 - [ ] secondary key;
482 - [x] foreign key;
483 - [ ] alternate key;
484
485 #### Q55. In recent versions of MySQL (8.0+), what's the correct syntax to declare a CTE (Common Table Expression)?
486
487 - [ ] WITH (SELECT id FROM users) as cte, SELECT ...
488 - [ ] WITH (SELECT id FROM users) as cte SELECT ...
489 - [ ] WITH cte as (SELECT id FROM users), SELECT ...
490 - [x] WITH cte as (SELECT id FROM users) SELECT ...
491
492 #### Q56. What is one reason to introduce data redundancy into a normalized database design?
493
494 - [x] to reduce corruption in data
495 - [ ] to reduce storage space
496 - [x] to make the system faster
497 - [ ] to prevent data anomalies
498
499 Note: "to make the system faster" can also be correct. For example we can calculate some heavy query in advance and store its result in s
500
501 #### Q57. The code snippet below is used to read data from an XML file into a table. Which XML structure is \_not\_ supported by the stat
502
503 ```mysql
504 LOAD XML LOCAL INFILE 'cars.xml'
505 INTO TABLE cars
506 ROWS IDENTIFIED BY `<car>`;
507 ```
508
509 - [ ] A
510
511 ```xml
512 <car>
513 <field name="make"> Lexus </field>
514 <field name="model"> IS300 </field>
515 <field name="make"> 2016 </field>
516 </car>
517 ```
518
519 - [x] B
520
521 ```xml
522 <car name="make"> Dodge </car>
523 <car name="model"> Ram </car>
524 <car name="year"> 2000 </car>
525 ```
526
527 - [ ] C
528
529 ```xml
530 <car make="Ford" model="Mustang" year="2002"/>
531 ```
532
533 - [ ] D
534
535 ```xml
536 <car year="2010">
537 <make>Mercedes</make> <model> C-Class</model>
538 </car>
539 ```
540
541 #### Q58. You are loading data into a table. Which command can you use to make sure that all data is inserted and duplicates rows are dis
542
543 - [x] `INSERT IGNORE`
544 - [ ] `INSERT UNIQUE`
545 - [ ] `INSERT INTO`
546 - [ ] `INSERT DISTINCT`
547
548 #### Q59. Which statement about the `TRUNCATE TABLE` statement is true?
549
550 - [ ] It will stop and issue an error when it encounters a row that is referenced by a row in a child table.
551 - [x] It always first drops, then re-creates a new table.
552 - [ ] It deletes rows one by one on tables with foreign key constraints.
553 - [x] It does not invoke the `DELETE` triggers associated with the table.
554
555 Note: both answers are correct - see [TRUNCATE TABLE Statement](https://dev.mysql.com/doc/refman/8.0/en/truncate-table.html) in MySQL man
556
557 #### Q60. You are working with the tables as shown in this diagram. You need to get the number of cars sold per the home state of each cu
558
559 ![mysql Q61](images/mysql_q61.png?raw=true)
560
561 - [ ] `SELECT state, COUNT(*) FROM customers WHERE ID IN (SELECT customerID FROM purchases) GROUP BY state;`
562 - [ ] `SELECT state, COUNT(*) FROM customers c LEFT JOIN purchases p ON c.ID = p.customerID GROUP BY state;`
563 - [x] `SELECT state, COUNT(*) FROM customers c, purchases p WHERE c.ID = p.customerID GROUP BY state;`
564 - [ ] `SELECT state, COUNT(*) FROM customers GROUP BY state;`
565
566 Explanation: THe difference between 2 and 3 is that LEFT JOIN will return 1 row per customer before grouping. If replaced with RIGHT JOIN
567
568 #### Q61. In data migration, there is often a need to delete duplicate rows as part of data cleanup. Which statement works best?
569
570 - [ ] `DELETE DUPS`
571 - [ ] `DELETE DISTINCT`
572 [x] `DELETE JOIN`
572 - [x] DELETE JOIN
573 - [ ] `DELETE WITH`
574
575 #### Q62. When working with MySQL cursor, what must you also declare?
576
577 - [ ] `DEFAULT` value
578 - [ ] `RETURN` variable
579 - [ ] `SQLEXCEPTION` routine
580 - [x] `NOT FOUND` handler
581
582 #### Q63. Which type of backup includes all the changes made to the data since the last full backup was performed?
583
584 - [ ] snapshot
585 - [ ] logical
586 - [x] differential
587 - [ ] incremental
588
589 #### Q64. You need to restore a MySQL database from a backup file. Which command-line tool do you use for the actual data import, after r
590
591 - [ ] `mysqld`
592 - [x] `mysql`
593 - [ ] `mysqladmin`
594 - [ ] `mysqldump`
595
596 #### Q65. You are importing data as JSON into a new table. You run CREATE TABLE json_data ( city JSON ); and insert rows into this table.
597
598 - [ ] `SELECT city FROM json_data;`
599 - [x] `SELECT city->>'$.name' city FROM json_data;`
600 - [ ] `SELECT city.name city FROM json_data;`
601 - [ ] `SELECT city->'$.name' city FROM json_data;`
602
603 Note: the last option is valid too but the results will be enclosed with quotation marks
604
605 #### Q66. If you want to use MyISAM instead of InnoDB, which option do you need to specify in the CREATE TABLE statement?
606
607 - [x] ENGINE
608 - [ ] PARTITION
609 - [ ] STORAGE
610 - [ ] TABLESPACE
611
612 #### Q67. You are working with the table in this diagram. You want to use full-text search to find the customers who live on a street or
613
614 Table name: **customers**
615
616 | ID | lastname | firstname | phone | address | city | state | zip |
617 | ---- | -------- | --------- | ------------ | ------------------- | ----------- | ----- | ----- |
618 | A001 | Smith | Bob | 212-555-1212 | 1001 1st Street | New York | NY | 10001 |
619 | A002 | Chang | John | 213-555-5678 | 888 Rodeo Drive | Los Angeles | CA | 90210 |
620 | A003 | Smith | Mary | 999-999-9999 | 123 Main Street | Anytown | VA | 12345 |
621 | A004 | Johnson | Jack | 312-312-3120 | 1111 Chicago Avenue | Chicago | IL | 60606 |
622 | A005 | Lopez | Linda | 737-777-3333 | 123 Main Street | Austin | TX | 73344 |
623
624 - [ ] A
625
626 ```sql
627 SELECT *
628 FROM customers
629 WHERE address MATCH 'Street' OR 'Drive';
630 ```
631
632 - [ ] B
633
634 ```sql
635 SELECT *
636 FROM customers
637 WHERE MATCH(address) IN ('street, drive');
638 ```
639
640 - [ ] C
641
642 ```sql
643 SELECT *
644 FROM customers
645 WHERE address MATCH 'Street' OR address MATCH 'Drive';
646 ```
647
648 - [x] D
649
650 ```sql
651 SELECT *
652 FROM customers
653 WHERE MATCH(address) AGAINST ('street, drive');
654 ```
655
656 #### Q68. Which query lists the databases on the current server?
657
658 - [x] SHOW DATABASES;
659 - [ ] LIST ALL DATABASES;
660 - [ ] LIST DATABASES;
661 - [ ] SHOW DB;
662
663 #### Q69. What is the product of the database designing phase?
664
665 - [ ] all tables, columns, data types, indexes and their relationships
666 - [ ] a list of entities, their relationship, and constraints
667 - [ ] all tables and their names, which are needed to implement the logical model
668 - [x] a list of entities, their relationship, constraints, data types, and cardinalities
669
670 #### Q70. Which choice is _not_ a valid model for a stored procedure parameter?
671
672 - [ ] INOUT
673 - [ ] IN
674 - [ ] OUT
675 - [x] IN OUT
676
677 #### Q71. What is the advantage of using a temporary table instead of a heap table?
678
679 - [ ] The temporary table will be dropped when the database is restarted.
680 - [ ] Temporary tables can be shared among clients, which makes them more usable in group development environments.
681 - [x] The temporary table will be dropped as soon as your session disconnects.
682 - [ ] Creating a temporary table does not require any special privileges.
683
684 #### Q72. What is the maximum number of columns that can be used by a single table index?
685
686 - [ ] 2
687 - [ ] 4
688 - [ ] 8
689 - [x] 16
690
691 #### Q73. Which command will return a list of triggers in the current database?
692
693 - [ ] `DISPLAY TRIGGERS;`
694 - [x] `SHOW TRIGGERS;`
695 - [ ] `SELECT ALL TRIGGERS;`
696 - [ ] `SELECT * FROM information_schema.triggers;`
697
698 #### Q74. Which statement is true about TIMESTAMP and DATETIME data types?
699
700 - [ ] TIMESTAMP values require more bytes for storage than DATETIME values.
701 - [ ] TIMESTAMP is stored without timezone, and DATETIME is stored in UTC values.
702 - [x] TIMESTAMP and DATETIME are both stored without time zone.
703 - [ ] TIMESTAMP is stored in UTC values, and DATETIME is stored in without time zone.
704
705 #### Q75. What is the equivalent of the mysqladmin reload command?
706
707 - [ ] `mysqladmin flush-threads`
708 - [ ] `mysqladmin flush-tables`
709 - [x] `mysqladmin flush-privileges`
710 - [ ] `mysqladmin flush-all`
711
712 #### Q76. Explain the security aspect of stored procedures
713
714 - [ ] Stored procedures are not secure, because they can be executed from the command line as the root user
715 - [ ] Stored procedures are secure, because the owner of the stored procedure can decide to whom access is granted
716 - [x] Stored procedures are secure, because applications can be given access to stored procedures and not any underlying tables
717 - [ ] Stored procedures are not secure, because they can execute statements to drop tables or bulk delete data
718
719 #### Q77 How would you retrieve data on all the customers where no phone number is stored?
719 #### Q77. How would you retrieve data on all the customers where no phone number is stored?
720
721 - [ ] `SELECT * FROM customers WHERE PhoneNumber = NULL;`
722 - [ ] `SELECT * FROM customers WHERE PhoneNumber IS NOT VALID;`
723 - [x] `SELECT * FROM customers WHERE PhoneNumber IS NULL;`
724 - [ ] `SELECT * FROM customers WHERE PhoneNumber IS UNKNOWN;`
725
726 #### Q78. In the diagram below, the price field is declared as type DECIMAL. What would be a more efficient declaration for this field?
727
728 ![mysql picture](images/mysql_q80.png?raw=true)
729
730 - [ ] FLOAT
731 - [x] DECIMAL(10,2)
732 - [ ] NUMERIC
733 - [ ] DOUBLE
734
735 #### Q79. Which choice is `not` an available string type for a column?
736
737 - [ ] `ENUM`
738 - [ ] `SET`
739 - [x] `BIT`
740 - [ ] `CHAR`
741
742 Explnation: BIT is not a string type
743
744 #### Q80. This diagram shows what type of relationship between customers and cars?
745
746 ![mysql picture](images/mysql_q80.png?raw=true)
747
748 - [ ] one-to-many
749 - [ ] parent-child
750 - [x] many-to-many
751 - [ ] many-to-one
752
753 #### Q81. A stored routine is a set of SQL statements stored on the server and takes form as either a procedure or a function. Which stat
754
755 - [ ] `SELECT`
756 - [x] `USE`
757 - [ ] `SET`
758 - [ ] `DECLARE`
759
760 Explanation: Both `SET` and `DECLARE` are used to create variables. Reference: [MySQL STORED PROCEDURE Tutorial With Examples](https://ww
761
762 #### Q82. When a new student is added to a new database, you want new records to be created in the related tables such as Exam, Score and
763
764 - [x] trigger
765 - [ ] regular expression
766 - [ ] view
767 - [ ] index
768
769 #### Q83. In the diagram below, the ID fields are declared as type CHAR instead of INT . Which is NOT one of the possible reasons behind
770
771 ![mysql picture](images/mysql_q85.png?raw=true)
772
773 - [ ] The ID field needs to include letters and not just numbers.
774 - [ ] You can have a consistent format across all of the tables that require ID fields.
775 - [ ] The ID field needs to have leading 0s, which the INT data type would truncate.
776 - [x] The `CHAR(10)` data type is more efficient and space-saving.
777
778 #### Q84. Why would you use a common table expression (CTE)?
779
780 - [ ] To define queries for later reuse for the duration of the current session
781 - [ ] To create temporary tables that can be used to pre-select often-used result sets.
782 - [ ] To calculate a new single value from a result set and return it to the query parser.
783 - [x] To break down complex queries and allow reuse within a query.
784
785 Explanation: CTEs do not create temporary tables, they only work within a signle query. Reference: [13.2.15 WITH (Common Table Expression
786
787 #### Q85. Which option modifier tells a program not to exit with an error if it does not recognize the option, but instead to issue a war
788
789 - [ ] --verbose
790 - [ ] --skip
791 - [ ] --skip-error
792 - [x] --loose
793
794 Reference: [4.2.2.4 Program Option Modifiers](https://dev.mysql.com/doc/refman/8.0/en/option-modifiers.html)
795
796 #### Q86. What does this SQL statement return?
797
798 ```
799 SELECT name FROM students WHERE name REGEXP '^to';
800 ```
801
802 - [x] all names starting with "to," such as Tommy or Tony
803 - [ ] all names with "to," such as Roberto and Tommy
804 - [ ] all names without "to," such as Samantha or Kathryn
805 - [ ] all names ending with "to," such as Roberto
806
807 #### Q87. You are working with the tables as shown in the diagram. You need to generate the list of price totals for each make and model
808
809 ![mysql picture](images/mysql_q92.png?raw=true)
810
811 - [ ] UNION
812 - [ ] SHOW TOTALS
813 - [ ] UNION ALL
814 - [x] WITH ROLLUP
815
816 #### Q88. The left and right joins are also known as \_.
817
818 - [ ] Inner Join
819 - [ ] Natural Join
820 - [x] Outer Join
821 - [ ] Cartesian Join
822
823 #### Q89. What is the valid way to create a database view in MySQL?
824
825 - [ ] `CREATE VIEW v1 SELECT * FROM t1 WHERE col1 > 10;`
826 - [ ] `CREATE VIEW v1 AS BEGIN SELECT * FROM t1 END;`
827 - [ ] `CREATE VIEW v1 BEGIN SELECT * FROM t1 END;`
828 - [x] `CREATE VIEW v1 AS SELECT * FROM t1;`
829
830 #### Q90. Inside a transaction, several operations need to be performed. What would you do if an exception happens during that transactio
831
832 - [ ] `UNDO`
833 - [ ] `UNCOMMIT`
834 - [x] `ROLLBACK`
835 - [ ] `REVERSE`
836
837 #### Q91. What function finds the current time or date in MySQL?
838
839 - [ ] DATE()
840 - [ ] GETDATE()
841 - [x] CURDATE()
842 - [ ] CURRENT()
843
844 #### Q92. What is the correct usage of ENUM in MySQL?
845
846 - [ ] `Create table size (ENUM ('Small','Medium','Large'));`
847 - [ ] `Create table ENUM (name ('Small','Medium','Large'));`
848 - [ ] `Create table size (name: ENUM['Small','Medium','Large']);`
849 - [x] `Create table size (name ENUM('Small','Medium','Large'));`
850
851 #### Q93. The mysqldump command cannot generate output in **\_**.
852
853 - [x] JSON
854 - [ ] CSV
855 - [ ] XML
856 - [ ] TXT
857
858 #### Q94. You are working with the tables shown below. You need to generate the list of all cars, whether or not they had been sold. Whic
859
860 ![mysql picture](images/mysql_q98.png?raw=true)
861
862 - [ ] A
863
864 ```
865 SELECT cars.*, purchases.date
866 FROM cars RIGHT JOIN purchases
866 FROM cars RIGHT JOIN purchases
867 ON cars.ID = purchases.carID;
868 ```
869
870 - [ ] B
871
872 ```
873 SELECT cars.*, purchases.date
874 FROM cars INNER JOIN purchases
875 ON cars.ID = purchases.carID;
876 ```
877
878 - [ ] C
879
880 ```
881 SELECT cars.*, purchases.date
882 FROM cars JOIN purchases
883 ON cars.ID = purchases.carID;
884 ```
885
886 - [x] D
887
888 ```
889 SELECT cars.*, purchases.date FROM cars LEFT JOIN purchases ON cars.ID = purchases.carID;
890 ```
891
892 #### Q95. Which code snippet from a stored procedure should be rewritten as a CASE statement?
893
894 - [ ] A
895
896 ```
897 IF var1 THEN SET varA = var1;
898 ELSEIF var2 THEN SET varA = var2;
899 ELSEIF var3 THEN SET varA = var3;
900 ELSE SET varA = var4;
901 END IF;
902 ```
903
904 - [ ] B
905
906 ```
907 IF var1 = var2 THEN SET varA = var1;
908 ELSEIF var2 = var3 THEN SET varA = var2;
909 ELSEIF var3 = var4 THEN SET varA = var3;
910 ELSE SET varA = var4;
911 END IF;
912 ```
913
914 - [ ] C
915
916 ```
917 IF var1 = 1 THEN SET varA = var1;
918 ELSEIF var2 = 2 THEN SET varA = var2;
919 ELSEIF var3 = 3 THEN SET varA = var3;
920 ELSE SET varA = var4;
921 END IF;
922 ```
923
924 - [x] D
925
926 ```
927 IF var1 = 1 THEN SET varA = var1;
928 ELSEIF var1 = 2 THEN SET varA = var2;
929 ELSEIF var1 = 3 THEN SET varA = var3;
930 ELSE SET varA = var4;
931 END IF;
932 ```
933
934 #### Q96. Why would you use stored functions?
935
936 - [x] for formulas and business rules that you want to apply to columns in an SQL query
937 - [ ] for formulas and business rules that should be applied on a specific trigger event like on inserts
938 - [ ] to automatically modify the data of a table based on a query
939 - [x] for reusing recurring queries
940
941 #### Q97. What steps do you need to take to normalize the table from this diagram?
942
943 Table name: superheroes
944 | name | alias | power1 | power2 | power3 |
945 | ---- | ----- | ------ | ------ | ------ |
946 | Superman | Clark Kent | Flight | X-Ray Vision | Super Strength |
947 | Wonder Woman | Diana Prince | Force Fields | Reflexes | Telepathy |
948 | Spider-man | Peter Parker | Walcrawling | Web-making | Enhanced Senses |
949 | Aquaman | Arthur Curry | Underwater Breathing | Enhanced Sight | Stamina |
950 | Hulk | Bruce Banner | Super Strength | Radiation Immunity | Invulnerability |
951
952 - [x] Create another table to serve as a lookup for powers with fields for code and description, as well as a junction table with superhe
953 - [ ] Add a column to this table to serve as a record identifier, and make it the primary key.
954 - [ ] Extend this table to have additional columns "power4," "power5," and so on, to allow additional powers for each superhero.
955 - [ ] Convert this table to have column called "power," and add one record for each superhero-power combination, for a total of 15 record
956
957 #### Q98. A table Item has a Boolean field endOfLife and a field makeYear of type YEAR(4). How can you set the Boolean to true for all It
958
959 - [ ] UPSERT Item SET endOfLife = true WHERE makeYear < 2019
960 - [ ] CHANGE Item SET endOfLife = true WHERE makeYear < 2019
961 - [ ] ALTER Item SET endOfLife = true WHERE makeYear < 2019
962 - [x] UPDATE Item SET endOfLife = true WHERE makeYear < 2019
963
964 #### Q99. Which choice is an example of an aggregate function?
965
966 - [ ] NOW()
967 - [ ] MID()
968 - [ ] FORMAT()
969 - [x] COUNT()
970
971 [Reference](https://www.sqltutorial.org/sql-aggregate-functions/)
972
973 #### Q100. You are working on UPDATE trigger on the employee tablein this diagram. How can you access the new value for the address insid
974
975 ![mysql picture](images/mysql_q116.png?raw=true)
976
977 - [x] Use NEW.address
978 - [ ] Use INSERTED.address
979 - [ ] Use DELETED.address
980 - [ ] USE OLD.address
981
982 [Reference](https://dev.mysql.com/doc/refman/8.0/en/trigger-syntax.html)
983
984 #### Q101. You are working with the tables as shown in this diagram. You need to generate the list of customers who purchased certain car
985
986 ![Q104](https://github.com/Ebazhanov/linkedin-skill-assessments-quizzes/assets/22109189/5c73a5c5-3e8b-4110-8068-dca25b323e57)
987
988 - [ ] UNION ALL
989 - [x] UNION
990 - [ ] SHOW TOTALS
991 - [ ] WITH ROLLUP
992
993 #### Q102. How would you make a case-insensitive query in MySQL?
994
995 - [ ] `SELECT * FROM customers WHERE UPPEERCASE(LastName) = 'POTTER';`
996 - [ ] `SELECT * FROM customers WHERE LOWERCASE(LastName) = 'potter';`
997 - [x] `SELECT * FROM customers WHERE UPPER(LastName) = 'POTTER';`
998 - [ ] `SELECT * FROM customers WHERE UPPER(LastName) = 'Potter';`
999
1000 #### Q103. "COUNT" keyword belongs to which categories in Mysql?
1001
1002 - [x] Aggregate functions
1003 - [ ] Operators
1004 - [ ] Clauses
1005 - [ ] All of the mentioned`
1006
1007 #### Q104. What is the meaning of "HAVING" clause in Mysql?
1008
1009 - [ ] To filter out the column values
1010 - [x] To filter out the row values
1011 - [ ] To filter out the row and column values
1012 - [ ] None of the mentioned
1013
1013
1014 #### Q105. Which clause is similar to "HAVING" clause in Mysql?
1015
1016 - [ ] SELECT
1017 - [ ] FROM
1018 - [x] WHERE
1019 - [ ] None of the mentioned
1020
1021 #### Q106. What will be the output of the following MySQL command?
1022
1023 SELECT emp_id, fname, lname
1024 FROM employee
1025 WHERE title=’HEAD TELLER’ AND start_date&gt;2008-11-23;
1026
1027 - [ ] All columns
1028 - [ ] Only those columns which are mention with "SELECT" clause
1029 - [x] Columns mention with "SELECT" clause and only those rows which contain 'HEAD TELLER' as a "title"
1030 - [ ] None of the mentioned
1031
1032 #### Q107. Is there any error in the following MySQL statement?
1033
1034 SELECT e.emp_id, e.fname,e.lname,d.name
1035 FROM employee e INNER JOIN department d
1036 ON e.dept_id=e.dept_id;
1037
1038 - [x] NO
1039 - [ ] YES
1040 - [ ] DEPEND
1041 - [ ] None of the mentioned
1042
1043 #### Q108. With MySQL, how do you select all the records from a table named "Persons" where the "LastName" is alphabetically between (and
1044
1045 - [ ] `SELECT LastName>'Hansen' AND LastName<'Pettersen' FROM Persons`
1046 - [x] `SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'`
1047 - [ ] `SELECT * FROM Persons WHERE LastName>'Hansen' AND LastName<'Pettersen'`
1048 - [ ] `None of the above.`
1049
1050 [Reference](https://www.w3schools.com/mysql/mysql_between.asp)
1051
1052 #### Q109. Consider the set of relations given below and the SQL query that follows
1053
1054 Students : (Roll number, Name, Date of birth)
1055 Courses: (Course number, Course name, instructor)
1056 Grades: (Roll number, Course number, Grade)
1057 SELECT DISTINCT Name
1058 FROM Students, Courses, Grades
1059 WHERE Students.Roll_number = Grades.Roll_number
1060 AND Courses.Instructor =Sriram
1061 AND Courses.Course_number = Grades.Course_number
1062 AND Grades.Grade = A
1063
1064 (Which of the following sets is computed by the above query?)
1065
1066 - [ ] Names of Students who have got an A grade in all courses taught by Sriram
1067 - [ ] Names of Students who have got an A grade in all courses
1068 - [x] Names of Students who have got an A grade in at least one of the courses taught by Sriram
1069 - [ ] None of the above
1070
1071 #### Q110. You are working with the tables shown below. You need to make sure that any record added to the purchases table consists of a
1072
1073 ![mysql picture](images/mysql_q85.png?raw=true)
1074
1075 - [ ] IF EXISTS
1076 - [ ] CROSS JOIN
1077 - [x] BEFORE INSERT
1078 - [ ] AFTER INSERT]
1079
1080 `IF EXISTS` and `CROSS JOIN` are not valid for a trigger.
1081
1082 #### Q111. Current versions of MySQL support the full-text search feature on some storage engines, as an alternative to using the LIKE op
1083
1084 - [x] ALTER TABLE car ADD FULL TEXT(description);
1085 - [ ] MERGE TABLE car ADD FULL TEXT(description)
1086 - [ ] ENABLE FULL TEXT(description) car
1087 - [ ] SEARCH FULL TEXT(description) car
1088
1089 #### Q112. Which statement would you _not_ use to filter data?
1090
1091 ![image](https://github.com/Ebazhanov/linkedin-skill-assessments-quizzes/assets/22109189/9cb0ae9d-1f6b-4f85-9d2f-44b6a7afd00c)
1092
1093 - [x] GROUP_BY
1094 - [ ] MATCH
1095 - [ ] WHERE
1096 - [ ] LIKE
1097
1098 #### Q113. In MySQL, which JOIN type returns all rows from the left table and the matching rows from the right table, and fills in with N
1099
1100 - [ ] INNER JOIN
1101 - [x] LEFT JOIN (or LEFT OUTER JOIN)
1102 - [ ] RIGHT JOIN (or RIGHT OUTER JOIN)
1103 - [ ] FULL JOIN (or FULL OUTER JOIN)
1104
1105 #### Q114. What does SQL stand for in MySQL?
1106
1107 - [x] Structured Query Language
1108 - [ ] Simple Query Language
1109 - [ ] System Query Language
1110 - [ ] Structured Question Language
1111
1112 #### Q115. Which MySQL statement is used to select data from a database?
1113
1114 - [ ] Extract
1115 - [x] select
1116 - [ ] get
1117 - [ ] Open
1118
1119 #### Q116. What is the purpose of the `PRIMARY KEY` in a MySQL table?
1120
1121 - [x] To create a unique index on a table
1122 - [ ] To define a column as an integer
1123 - [ ] To define the data type of a column
1124 - [ ] To specify a foreign key reference
1125
1126 [Reference](<https://www.w3schools.com/mysql/mysql_primarykey.asp#:~:text=The%20PRIMARY%20KEY%20constraint%20uniquely,or%20multiple%20col
1127
1128 #### Q117. Which of the following is a valid SQL query to insert a new row into the users table?
1129
1130 - [x] `INSERT INTO users (name, email) VALUES ('John Doe', '[email protected]')`
1131 - [ ] `ADD users (name, email) VALUES ('John Doe', '[email protected]')`
1132 - [ ] `CREATE users (name, email) VALUES ('John Doe', '[email protected]')`
1133 - [ ] `UPDATE users (name, email) VALUES ('John Doe', '[email protected]')`
1134
1135 #### Q118. Which of the following is a valid SQL query to delete the row with the id of 2 from the users table?
1136
1137 - [x] `DELETE FROM users WHERE id = 2`
1138 - [ ] `REMOVE FROM users WHERE id = 2`
1139 - [ ] `DROP users WHERE id = 2`
1140 - [ ] `TRUNCATE users WHERE id = 2`
1141
1142 #### Q119. MySQL programs are a set of command-line utilities that are provided with typical MySQL distributions. MySQL is designed to be
1143
1144 - [ ] database and programming
1145 - [ ] user and administrator
1146 - [x] client and server
1147 - [ ] syntax and objects
1148
1149 #### Q120. Which MySQL command shows the structure of a table?
1150
1151 - [ ] INFO table;
1152 - [ ] SHOW table;
1153 - [ ] STRUCTURE table;
1154 - [x] DESCRIBE table;
1155
1156 #### Q121. The left and right joins are also known as \_.
1157
1158 - [ ] Inner Join
1159 - [ ] Natural Join
1160 [x] Outer Join
1160 - [x] Outer Join
1161 - [ ] Cartesian Join
1162
1163 #### Q122. What is the valid way to create a database view in MySQL?
1164
1165 - [ ] `CREATE VIEW v1 SELECT * FROM t1 WHERE col1 > 10;`
1166 - [ ] `CREATE VIEW v1 AS BEGIN SELECT * FROM t1 END;`
1167 - [ ] `CREATE VIEW v1 BEGIN SELECT * FROM t1 END;`
1168 - [x] `CREATE VIEW v1 AS SELECT * FROM t1;`
1169
1170 #### Q123. In a database with a "Students" table containing information about students, which SQL statement is used to retrieve the names
1171
1172 - [ ] A
1173
1174 ```
1175 SELECT student_name FROM Students WHERE score > 90;
1176 ```
1177
1178 - [x] B
1179
1180 ```
1181 SELECT name FROM Students WHERE score > 90;
1182 ```
1183
1184 - [ ] C
1185
1186 ```
1187 SELECT student_name FROM Students WHERE exam_score > 90;
1188 ```
1189
1190 - [ ] D
1191
1192 ```
1193 SELECT name FROM Students WHERE exam_score > 90;
1194 ```
1195
1196 #### Q124 Which SQL command is used to retrieve data from a database?
1197
1198 - [ ] FETCH
1199 - [ ] SEARCH
1200 - [x] SELECT
1201 - [ ] EXTRACT

You might also like