MySQL 8 Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

  1. Download the zipped file:
shell> wget 'https://codeload.github.com/datacharmer/test_db/zip/master' -O master.zip
  1. Unzip the file:
shell> unzip master.zip
  1. Load the data:
shell> cd test_db-master

shell> mysql -u root -p < employees.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
INFO
CREATING DATABASE STRUCTURE
INFO
storage engine: InnoDB
INFO
LOADING departments
INFO
LOADING employees
INFO
LOADING dept_emp
INFO
LOADING dept_manager
INFO
LOADING titles
INFO
LOADING salaries
data_load_time_diff
NULL
  1. Verify the data:
shell> mysql -u root -p  employees -A
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 8.0.3-rc-log MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SHOW TABLES;
+-------------------------+
| Tables_in_employees |
+-------------------------+
| current_dept_emp |
| departments |
| dept_emp |
| dept_emp_latest_date |
| dept_manager |
| employees |
| salaries |
| titles |
+-------------------------+
8 rows in set (0.00 sec)
mysql> DESC employees\G
*************************** 1. row ***************************
Field: emp_no
Type: int(11)
Null: NO
Key: PRI
Default: NULL
Extra:
*************************** 2. row ***************************
Field: birth_date
Type: date
Null: NO
Key:
Default: NULL
Extra:
*************************** 3. row ***************************
Field: first_name
Type: varchar(14)
Null: NO
Key:
Default: NULL
Extra:
*************************** 4. row ***************************
Field: last_name
Type: varchar(16)
Null: NO
Key:
Default: NULL
Extra:
*************************** 5. row ***************************
Field: gender
Type: enum('M','F')
Null: NO
Key:
Default: NULL
Extra:
*************************** 6. row ***************************
Field: hire_date
Type: date
Null: NO
Key:
Default: NULL
Extra:
6 rows in set (0.00 sec)