如何让MySQL员工练习?

时间:2017-04-10 07:11:56

标签: java mysql jdbc

我从https://dev.mysql.com/doc/employee/en/

获得了员工示例数据库

并导入我的mysql。

    mysql> use employees;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
    mysql> show tables;
    +----------------------+
    | Tables_in_employees  |
    +----------------------+
    | current_dept_emp     |
    | departments          |
    | dept_emp             |
    | dept_emp_latest_date |
    | dept_manager         |
    | employees            |
    | salaries             |
    | test                 |
    | titles               |
    +----------------------+
    9 rows in set (0.00 sec)
    mysql> describe employees;
    +------------+---------------+------+-----+---------+-------+
    | Field      | Type          | Null | Key | Default | Extra |
    +------------+---------------+------+-----+---------+-------+
    | emp_no     | int(11)       | NO   | PRI | NULL    |       |
    | birth_date | date          | NO   |     | NULL    |       |
    | first_name | varchar(14)   | NO   |     | NULL    |       |
    | last_name  | varchar(16)   | NO   |     | NULL    |       |
    | gender     | enum('M','F') | NO   |     | NULL    |       |
    | hire_date  | date          | NO   |     | NULL    |       |
    +------------+---------------+------+-----+---------+-------+
    6 rows in set (0.00 sec)

    mysql> describe departments;
    +-----------+-------------+------+-----+---------+-------+
    | Field     | Type        | Null | Key | Default | Extra |
    +-----------+-------------+------+-----+---------+-------+
    | dept_no   | char(4)     | NO   | PRI | NULL    |       |
    | dept_name | varchar(40) | NO   | UNI | NULL    |       |
    +-----------+-------------+------+-----+---------+-------+
    2 rows in set (0.00 sec)

现在我想用这个数据库进行练习。

但是我无法找到该数据库的任何parctice主题。

例如给我一个问题包括一些条件然后让我写sql来解决这个问题。

像:

显示emp表中的员工详细信息。

SELECT * FROM EMP;

显示10号部门所有员工的员工姓名和工资。

SELECT ename, sal FROM EMP WHERE deptno=10;

显示为20号部门工作的所有员工的员工姓名,部门编号和工资,以及超过2500的工资。

SELECT ename, deptno, sal FROM emp WHERE deptno=20 AND sal>2500;

如果你知道请告诉我,谢谢!

1 个答案:

答案 0 :(得分:1)

您可以从github https://github.com/datacharmer/test_db

下载数据