Exercises

  1. Write the monitor command to import the file academics.tsv, which has its values separated by tabs, into the details table. Hint: the tab character is shown with the \t escape sequence.

  2. When would you need to insert data using a query?

  3. What’s the difference between REPLACE and INSERT IGNORE?

  4. What can you tell from this output produced by the EXPLAIN command?

    +----+-------------+------------+-------+---------------+---------+...
    | id | select_type | table      | type  | possible_keys | key     |...
    +----+-------------+------------+-------+---------------+---------+...
    |  1 | SIMPLE      | supervisor | const | PRIMARY       | PRIMARY |...
    |  1 | SIMPLE      | student    | ALL   | NULL          | NULL    |...
    |  1 | SIMPLE      | supervises | index | NULL          | PRIMARY |...
    +----+-------------+------------+-------+---------------+---------+...
    ... +---------+-------+------+------------------------------------+
    ... | key_len | ref   | rows | Extra                              |
    ... +---------+-------+------+------------------------------------+
    ... |       4 | const |    1 | Using index; Using temporary       |
    ... |    NULL | NULL  |   95 |                                    |
    ... |      12 | NULL  |  570 | Using where; Using index; Distinct |
    ... +---------+-------+------+------------------------------------+
    3 rows in set (0.00 sec)
  5. What can you tell from this output produced by the EXPLAIN command?

    +-----+--------------+------------+--------+---------------+---------+---------+... | id | select_type | table | type | possible_keys | key | key_len |... +-----+--------------+------------+--------+---------------+---------+---------+... ...

Get Learning MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.