导入 Mysql 示例数据库 employees
Mysql也有跟Oracle的scott与employees相似的数据库,这样就免除了每次都要自己建表并插入数据了。 Mysql提供的供练习使用的数据库employees,下面地址:https://launchpad.net/test-db/employees-db-1/1.0.6
下载其中的employees_db-full-1.0.6.tar.bz2,之后按下列步骤解压缩,并安装。
1、解压文件
[root@rac1 opt]# tar -xjf employees_db-full-1.0.6.tar.bz2
[root@rac1 opt]# cd employees_db
[root@rac1 employees_db]# ls -al
总计 164724
drwxr-xr-x 2 root root 4096 09-10 19:33 .
drwxr-xr-x 4 root root 4096 09-10 19:33 ..
-rw-r--r-- 1 501 games 752 2009-03-30 Changelog
-rw-r--r-- 1 501 games 161 2008-10-09 ._employees_partitioned2.sql
-rw-r--r-- 1 501 games 6460 2008-10-09 employees_partitioned2.sql
-rw-r--r-- 1 501 games 7624 2009-02-06 employees_partitioned3.sql
-rw-r--r-- 1 501 games 5660 2009-02-06 employees_partitioned.sql
-rw-r--r-- 1 501 games 161 2008-11-28 ._employees.sql
-rw-r--r-- 1 501 games 3861 2008-11-28 employees.sql
-rw-r--r-- 1 501 games 161 2008-07-30 ._load_departments.dump
-rw-r--r-- 1 501 games 241 2008-07-30 load_departments.dump
-rw-r--r-- 1 501 games 13828291 2009-03-30 load_dept_emp.dump
-rw-r--r-- 1 501 games 161 2008-07-30 ._load_dept_manager.dump
-rw-r--r-- 1 501 games 1043 2008-07-30 load_dept_manager.dump
-rw-r--r-- 1 501 games 161 2008-07-30 ._load_employees.dump
-rw-r--r-- 1 501 games 17422825 2008-07-30 load_employees.dump
-rw-r--r-- 1 501 games 161 2008-07-30 ._load_salaries.dump
-rw-r--r-- 1 501 games 115848997 2008-07-30 load_salaries.dump
-rw-r--r-- 1 501 games 161 2008-07-30 ._load_titles.dump
-rw-r--r-- 1 501 games 21265449 2008-07-30 load_titles.dump
-rw-r--r-- 1 501 games 3889 2009-03-30 objects.sql
-rw-r--r-- 1 501 games 2211 2008-07-30 README
-rw-r--r-- 1 501 games 161 2008-07-30 ._README
-rw-r--r-- 1 501 games 4455 2009-03-30 test_employees_md5.sql
-rw-r--r-- 1 501 games 4450 2009-03-30 test_employees_sha.sql
2、安装过程
[root@rac1 employees_db]# mysql -u root -p < employees.sql
Enter password:
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
3、检查安装的表有哪些
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 |
+---------------------+
| departments |
| dept_emp |
| dept_manager |
| employees |
| salaries |
| titles |
+---------------------+
6 rows in set (0.04 sec)
4、employees.sql的内容(Innodb存储引擎,前面create table是创建表的脚本,后面source往表里插入数据):
[root@rac1 employees_db]# cat employees.sql
-- Sample employee database
-- See changelog table for details
-- Copyright (C) 2007,2008, MySQL AB
--
-- Original data created by Fusheng Wang and Carlo Zaniolo
-- http://www.cs.aau.dk/TimeCenter/software.htm
-- http://www.cs.aau.dk/TimeCenter/Data/employeeTemporalDataSet.zip
--
-- Current schema by Giuseppe Maxia
-- Data conversion from XML to relational by Patrick Crews
--
-- This work is licensed under the
-- Creative Commons Attribution-Share Alike 3.0 Unported License.
-- To view a copy of this license, visit
-- http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to
-- Creative Commons, 171 Second Street, Suite 300, San Francisco,
-- California, 94105, USA.
--
-- DISCLAIMER
-- To the best of our knowledge, this data is fabricated, and
-- it does not correspond to real people.
-- Any similarity to existing people is purely coincidental.
--
DROP DATABASE IF EXISTS employees;
CREATE DATABASE IF NOT EXISTS employees;
USE employees;
SELECT 'CREATING DATABASE STRUCTURE' as 'INFO';
DROP TABLE IF EXISTS dept_emp,
dept_manager,
titles,
salaries,
employees,
departments;
set storage_engine = InnoDB;
-- set storage_engine = MyISAM;
-- set storage_engine = Falcon;
-- set storage_engine = PBXT;
-- set storage_engine = Maria;
select CONCAT('storage engine: ', @@storage_engine) as INFO;
CREATE TABLE employees (
emp_no INT NOT NULL,
birth_date DATE NOT NULL,
first_name VARCHAR(14) NOT NULL,
last_name VARCHAR(16) NOT NULL,
gender ENUM ('M','F') NOT NULL,
hire_date DATE NOT NULL,
PRIMARY KEY (emp_no)
);
CREATE TABLE departments (
dept_no CHAR(4) NOT NULL,
dept_name VARCHAR(40) NOT NULL,
PRIMARY KEY (dept_no),
UNIQUE KEY (dept_name)
);
CREATE TABLE dept_manager (
dept_no CHAR(4) NOT NULL,
emp_no INT NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
KEY (emp_no),
KEY (dept_no),
FOREIGN KEY (emp_no) REFERENCES employees (emp_no) ON DELETE CASCADE,
FOREIGN KEY (dept_no) REFERENCES departments (dept_no) ON DELETE CASCADE,
PRIMARY KEY (emp_no,dept_no)
);
CREATE TABLE dept_emp (
emp_no INT NOT NULL,
dept_no CHAR(4) NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
KEY (emp_no),
KEY (dept_no),
FOREIGN KEY (emp_no) REFERENCES employees (emp_no) ON DELETE CASCADE,
FOREIGN KEY (dept_no) REFERENCES departments (dept_no) ON DELETE CASCADE,
PRIMARY KEY (emp_no,dept_no)
);
CREATE TABLE titles (
emp_no INT NOT NULL,
title VARCHAR(50) NOT NULL,
from_date DATE NOT NULL,
to_date DATE,
KEY (emp_no),
FOREIGN KEY (emp_no) REFERENCES employees (emp_no) ON DELETE CASCADE,
PRIMARY KEY (emp_no,title, from_date)
);
CREATE TABLE salaries (
emp_no INT NOT NULL,
salary INT NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
KEY (emp_no),
FOREIGN KEY (emp_no) REFERENCES employees (emp_no) ON DELETE CASCADE,
PRIMARY KEY (emp_no, from_date)
);
SELECT 'LOADING departments' as 'INFO';
source load_departments.dump ;
SELECT 'LOADING employees' as 'INFO';
source load_employees.dump ;
SELECT 'LOADING dept_emp' as 'INFO';
source load_dept_emp.dump ;
SELECT 'LOADING dept_manager' as 'INFO';
source load_dept_manager.dump ;
SELECT 'LOADING titles' as 'INFO';
source load_titles.dump ;
SELECT 'LOADING salaries' as 'INFO';
source load_salaries.dump ;
导入 Mysql 示例数据库 employees的更多相关文章
- MySQL 示例数据库 employees 详解
[引子] IT这一行在我看来是比较要求动手能力的,但是人非生而知之:人们身上的技能除了一些本能之外,大多都是通过学习而得到的. 前一段时间一直在整理素材,写一个关于explain 的系列文章:在一开始 ...
- Mysql示例数据库employees.sql导入问题
Mysql版本:Server version: 5.7.9-log MySQL Community Server (GPL) 问题一.Unknown system variable 'storage_ ...
- 导入MySQL测试数据库employee报错
导入MySQL测试数据库employee 报错 下载地址:https://launchpad.net/test-db/ 上传解压: [root@001 ~]# tar xf employees_db- ...
- MySQL示例数据库导入_1
做个测试需要有适当量的数据库,于是找到了下面这个MySQL(超过30w记录), 1)先Git clone https://github.com/datacharmer/test_db ...
- MySQL 示例数据库
微软 SQL Server 自带了一些示例数据库,可用于练习和测试.也可作为自己数据库设计时的参考.这些示例数据库开源在了 GitHub,可在 Microsoft/sql-server-samples ...
- MySQL 示例数据库sakila-db的安装
最近在看 “高性能MySql”这本神书,发现上面很多例子采用的官方示例数据库sakila. 官方示例数据库 下载地址 http://dev.mysql.com/doc/index-other.html ...
- mysql 示例数据库安装
示例数据库不和bin安装文件在一块, 安装数据库没有这个选项 https://dev.mysql.com/doc/index-other.html
- Windows MySQL测试数据库employees的导入
一: 首先下载employees测试数据库 https://launchpad.net/test-db/ 二:用文本编辑器打开其中的employees.sql文件,将第38行的set storage_ ...
- mysql 5.5 中的示例数据库 employees
http://dev.mysql.com/doc/employee/en/employees-installation.html
随机推荐
- c#导出Excel 使用EXCEL进程
private void exportExcel(string filename, string path,string title, List<ArchivedWcsTask> wcst ...
- Python基础复习_Unit one
一. 编译&&安装Python2.7 1.安装python第三方模块管理工具 easy_install --->> easy_install-2.7 pip Ipy ...
- [改善Java代码]构造代码块会想你所想
建议37: 构造代码块会想你所想 镜像博文:http://www.cnblogs.com/DreamDrive/p/5413408.html http://www.cnblogs.com/DreamD ...
- Oracle创建表空间、新建用户和授权
通过pl/sql以sys用户登录到Oracle数据库上,然后执行菜单:文件/新建/命令窗口 ,打开一个命令窗口然后在该命令窗口中执行脚本创建和删除表空间 . 1.创建表空间 格式: create t ...
- 会话跟踪技术——cookie
一.会话控制 为了使得网站可以跟踪客户端与服务器之间的交互,保存和记忆每个用户的身份和信息,我们需要一种强有力的解决方案,这样就产生了会话控制. HTTP是一个无状态的协议,此协议无法来维护两个事务之 ...
- android手机中图片的拖拉及浏览功能
配置文件 activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/andro ...
- 申请Android Map 的API Key(v2)的最新申请方式(SHA1密钥)
申请Android Map 的API Key(v2)的最新申请方式(SHA1密钥)具体步骤如下: ...
- C#——字符操作
题目要求:用户随机输入字母及数字组成的字符串,当用户连续输入字符串‘hello’时,程序结束用户输入,并分别显示用户输入的字母及数字的数目. 代码: using System; using Syste ...
- (转)实战Memcached缓存系统(2)Memcached Java API基础之MemcachedClient
1. 构造函数 public MemcachedClient(InetSocketAddress[] ia) throws IOException; public MemcachedClient(Li ...
- c# winform 点菜宝接口demo程序
前几天写了一篇关于c#调用 win32API的文章,有同学对点菜宝接口感兴趣,所以就把写的demo程序共享出来,大家一起讨论改进,so放百度云地址: 百度云下载地址