MySQL样本数据库Sakila<转>
2013-11-07 10:44
477 查看
《高性能MySQL》第三版,里面提到了MySQL提供的样本数据库Sakila,也使用Sakila作为演示。自己的的数据中也没有真实的数据用于测试,决定带Sakila数据库。这让想起了Microsoft为MS SqlServer默认提供北风数据库NorthWind。
大体步骤:
1、下载Sakila样本数据库,下载地址http://downloads.mysql.com/docs/sakila-db.tar.gz(下载页面http://dev.mysql.com/doc/index-other.html)。
2、导入sakila-schema.sql和sakila-data.sql文件。
3、测试
MySQL中导入Sakila的过程如下(MySQL网站原文,没有难以理解的地方就没有翻译,另外一方面我的英语翻译水平较差):
4. Installation
The Sakila sampledatabase is available from http://dev.mysql.com/doc/index-other.html.
Adownloadable archive is available in compressed tar fileor Zip format. The archive contains three files: sakila-schema.sql, sakila-data.sql, and sakila.mwb.
The sakila-schema.sql filecontains all the CREATE statements required to create the structure of theSakila database including tables, views, stored procedures,
and triggers.
The sakila-data.sql filecontains the INSERT statements required to populate the structurecreated by thesakila-schema.sql file,
along with definitions for triggers that mustbe created after the initial data load.
The sakila.mwb file is aMySQL Workbench data model that you can open within MySQL Workbench to examinethe database structure. For more information, see MySQL
Workbench.
To install theSakila sample database, follow these steps:
1. Extract the installation archive to a temporary locationsuch as C:\temp\ or /tmp/. When you unpackthe archive, it creates a directory named sakila-db thatcontains
the sakila-schema.sql and sakila-data.sql files.
2. Connect to the MySQL server using the mysql command-line client with the followingcommand:
3. shell> mysql -u root -p
Enter yourpassword when prompted. A non-root account can be used as long as the account hasprivileges to create new databases.
4. Execute the sakila-schema.sql script tocreate the database structure by using the following command:
5. mysql> SOURCE C:/temp/sakila-db/sakila-schema.sql;
Replace C:/temp/sakila-db with thepath to the sakila-schema.sql file on your system.
Note
On Windows youshould use slashes, rather than backslashes, when executing the SOURCE command.
6. Execute the sakila-data.sql script topopulate the database structure with the following command:
7. mysql> SOURCE C:/temp/sakila-db/sakila-data.sql;
Replace C:/temp/sakila-db with thepath to the sakila-data.sql file on your system.
8. Confirm that the sample database is installed correctly.Execute the following statements. You should see output similar to that shownhere.
9. mysql> USE sakila;
10.Database changed
11.
12.mysql> SHOW TABLES;
13.+----------------------------+
14.| Tables_in_sakila |
15.+----------------------------+
16.| actor |
17.| address |
18.| category |
19.| city |
20.| country |
21.| customer |
22.| customer_list |
23.| film |
24.| film_actor |
25.| film_category |
26.| film_list |
27.| film_text |
28.| inventory |
29.| language |
30.| nicer_but_slower_film_list |
31.| payment |
32.| rental |
33.| sales_by_film_category |
34.| sales_by_store |
35.| staff |
36.| staff_list |
37.| store |
38.+----------------------------+
39.22 rows in set (0.00 sec)
40.
41.mysql> SELECT COUNT(*) FROM film;
42.+----------+
43.| COUNT(*) |
44.+----------+
45.| 1000 |
46.+----------+
47.1 row in set (0.02 sec)
48.
49.mysql> SELECT COUNT(*) FROM film_text;
50.+----------+
51.| COUNT(*) |
52.+----------+
53.| 1000 |
54.+----------+
55.1 row in set (0.00 sec)
其余部分可以查看http://dev.mysql.com/doc/sakila/en/index.html#网页上的其它部分,
· Sakila Sample Database
o 1 Preface and Legal Notices
o 2 Introduction
o 3 History
o 4 Installation
o 5 Structure
o 6 Usage Examples
o 7 Acknowledgments
o 8 License for the Sakila Sample Database
o 9 Note for Authors
o 10 Sakila Change History
大体步骤:
1、下载Sakila样本数据库,下载地址http://downloads.mysql.com/docs/sakila-db.tar.gz(下载页面http://dev.mysql.com/doc/index-other.html)。
2、导入sakila-schema.sql和sakila-data.sql文件。
3、测试
MySQL中导入Sakila的过程如下(MySQL网站原文,没有难以理解的地方就没有翻译,另外一方面我的英语翻译水平较差):
4. Installation
The Sakila sampledatabase is available from http://dev.mysql.com/doc/index-other.html.
Adownloadable archive is available in compressed tar fileor Zip format. The archive contains three files: sakila-schema.sql, sakila-data.sql, and sakila.mwb.
The sakila-schema.sql filecontains all the CREATE statements required to create the structure of theSakila database including tables, views, stored procedures,
and triggers.
The sakila-data.sql filecontains the INSERT statements required to populate the structurecreated by thesakila-schema.sql file,
along with definitions for triggers that mustbe created after the initial data load.
The sakila.mwb file is aMySQL Workbench data model that you can open within MySQL Workbench to examinethe database structure. For more information, see MySQL
Workbench.
To install theSakila sample database, follow these steps:
1. Extract the installation archive to a temporary locationsuch as C:\temp\ or /tmp/. When you unpackthe archive, it creates a directory named sakila-db thatcontains
the sakila-schema.sql and sakila-data.sql files.
2. Connect to the MySQL server using the mysql command-line client with the followingcommand:
3. shell> mysql -u root -p
Enter yourpassword when prompted. A non-root account can be used as long as the account hasprivileges to create new databases.
4. Execute the sakila-schema.sql script tocreate the database structure by using the following command:
5. mysql> SOURCE C:/temp/sakila-db/sakila-schema.sql;
Replace C:/temp/sakila-db with thepath to the sakila-schema.sql file on your system.
Note
On Windows youshould use slashes, rather than backslashes, when executing the SOURCE command.
6. Execute the sakila-data.sql script topopulate the database structure with the following command:
7. mysql> SOURCE C:/temp/sakila-db/sakila-data.sql;
Replace C:/temp/sakila-db with thepath to the sakila-data.sql file on your system.
8. Confirm that the sample database is installed correctly.Execute the following statements. You should see output similar to that shownhere.
9. mysql> USE sakila;
10.Database changed
11.
12.mysql> SHOW TABLES;
13.+----------------------------+
14.| Tables_in_sakila |
15.+----------------------------+
16.| actor |
17.| address |
18.| category |
19.| city |
20.| country |
21.| customer |
22.| customer_list |
23.| film |
24.| film_actor |
25.| film_category |
26.| film_list |
27.| film_text |
28.| inventory |
29.| language |
30.| nicer_but_slower_film_list |
31.| payment |
32.| rental |
33.| sales_by_film_category |
34.| sales_by_store |
35.| staff |
36.| staff_list |
37.| store |
38.+----------------------------+
39.22 rows in set (0.00 sec)
40.
41.mysql> SELECT COUNT(*) FROM film;
42.+----------+
43.| COUNT(*) |
44.+----------+
45.| 1000 |
46.+----------+
47.1 row in set (0.02 sec)
48.
49.mysql> SELECT COUNT(*) FROM film_text;
50.+----------+
51.| COUNT(*) |
52.+----------+
53.| 1000 |
54.+----------+
55.1 row in set (0.00 sec)
其余部分可以查看http://dev.mysql.com/doc/sakila/en/index.html#网页上的其它部分,
· Sakila Sample Database
o 1 Preface and Legal Notices
o 2 Introduction
o 3 History
o 4 Installation
o 5 Structure
o 6 Usage Examples
o 7 Acknowledgments
o 8 License for the Sakila Sample Database
o 9 Note for Authors
o 10 Sakila Change History
相关文章推荐
- CentOS安装软件<一> MYSQL
- java查询mysql的char字段List<Object[]>数据被截断
- mysql半同步复制<二>
- <textarea>里的内容保存MYSQL后,页面输出不换行的解决方法
- php+js+mysql设计的仿webQQ-<1>邮箱验证
- com.mysql.jdbc.SQLError.<clinit>(SQLError.java:137)报错
- mysql 1005-Can't create table ''error:121&mysql error 1005 can't create table'<errno:150>
- 【MySql】使用记录<四>
- JDBC连接mysql<PreparedStatement>
- mysql修改表的存储引擎(myisam<=>innodb)
- [mysqldumpslow 报错] Died at /usr/local/mysql/bin/mysqldumpslow line 161, <> chunk 236.
- Maatkit工具使用<一>之mysql主从数据校验工具
- mysql快速优化<一>
- MySQL学习笔记之<MySQL数据类型>
- mysql 主从配置详解(windows<->ubuntu)
- php+js+mysql设计的仿webQQ-<4>登陆和注册
- Mysql登录提示1045 error:access denied for user 'root'@'localhost <using password: yes>
- mysql explain : inner join analysis ; <eq_ref> better than <ref>
- 【MySql】使用记录<三>
- linux mysql 找不到 <mysql/mysql.h>