Home  >  Article  >  Database  >  MySQL示例employees数据库

MySQL示例employees数据库

WBOY
WBOYOriginal
2016-06-07 17:35:241881browse

Oracle安装是附带安装employees数据,供练习sql使用。MySQL同样提供了employees数据库,但并未随数据库一起安装,其下载链接也极

Oracle安装是附带安装employees数据,供练习sql使用。MySQL同样提供了employees数据库,但并未随数据库一起安装,其下载链接也极其隐蔽,可能导致许多人没注意到。

下载地址:https://launchpad.net/test-db/employees-db-1/1.0.6

建议大家下载:employees_db-full-1.0.6.tar.bz2,解压缩,进入目录,并导入。

tar -xjf $HOME/Downloads/employees_db-full-1.0.4.tar.bz2
//解压缩,,进入目录
cd employees_db/
//导入数据库root为用户名
mysql -t -u root -p

创建表的SQL语句:

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 departments(
dept_no char(4),
dept_name varchar(40)
);
alter table departments
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);

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn