MySQL樣本employees資料庫

來源:互聯網
上載者:User

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 < employees.sql 

建立表的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);

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.