MySQL example employees Database

Source: Internet
Author: User

Oracle installation is accompanied by employees data for SQL exercises. MySQL also provides the employees database, but it is not installed with the database, and its download link is extremely hidden, which may cause many people to not notice.

: Https://launchpad.net/test-db/employees-db-1/1.0.6

We recommend that you download: employees_db-full-1.0.6.tar.bz2, extract, enter the directory, and import.

Tar-xjf $ HOME/Downloads/employees_db-full-1.0.4.tar.bz2
// Extract and enter the Directory
Cd employees_db/
// The root User Name of the imported Database
Mysql-t-u root-p <employees. SQL

SQL statement for creating a table:

Create table employees (
Emp_no int,
Birth_date date,
First_name varchar (14 ),
Last_name varchar (16 ),
Gender enum ('M', 'F '),
Hire_date date
);
Alter table employees
Add constraint emp_key primary key (emp_no );

Create table orders ments (
Dept_no char (4 ),
Dept_name varchar (40)
);
Alter table orders ments
Add constraint dept_key primary key (dept_no );

Create table dept_emp (
Emp_no int,
Dept_no char (4 ),
From_date date,
To_date date
);
Alter table dept_emp
Add constraint dept_emp_key primary key (emp_no, dept_no );

Create table dept_manager (
Dept_no char (4 ),
Emp_no int,
From_date date,
To_date date
);
Alter table dept_manager
Add constraint manager_key primary key (emp_no, dept_no );

Create table salaries (
Emp_no int,
Sarary int,
From_date date,
To_date date
);
Alter table salaries
Add constraint salaries_key primary key (emp_no, from_date );

Create table titles (
Emp_no int,
Title varchar (50 ),
From_date date,
To_date date
);
Alter table titles
Add constraint titles_key primary key (emp_no, title, from_date );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.