安装MySQL样本数据库Sakila

    通常情况下对于一个全新的MySQL服务器,没有任何数据供我们测试和使用。对此,MySQL为我们提供了一些样本数据库,我们可以基于这些数据库作基本的操作以及压力测试等等。本文描述的是安装sakila数据库。该数据库需要安装在MySQL 5.0以上的版本。以下是其描述。

 

1、下载种子数据库
下载位置:
http://dev.mysql.com/doc/index-other.html

 

2、安装种子数据库sakila
[root@localhost ~]# unzip sakila-db.zip
Archive:  sakila-db.zip
   creating: sakila-db/
  inflating: sakila-db/sakila-schema.sql 
  inflating: sakila-db/sakila.mwb   
  inflating: sakila-db/sakila-data.sql

The sakila-schema.sql file contains all the CREATE statements required to create the structure of the Sakila database including tables, views, stored procedures, and triggers.

 
The sakila-data.sql file contains the INSERT statements required to populate the structure created by the sakila-schema.sql file, along with definitions for triggers that must be created after the initial data load.


The sakila.mwb file is a MySQL Workbench data model that you can open within MySQL Workbench to examine the database structure. For more information, see MySQL Workbench.

[root@localhost ~]# ls
anaconda-ks.cfg  Desktop  install.log  install.log.syslog  sakila-db  sakila-db.zip
[root@localhost ~]# cd sakila-db
[root@localhost sakila-db]# ls
sakila-data.sql  sakila.mwb  sakila-schema.sql

[root@localhost sakila-db]# mysql -uroot -p <sakila-schema.sql
Enter password:

[root@localhost sakila-db]# mysql -uroot -p <sakila-data.sql
Enter password:

 

3、验证安装结果
[root@localhost sakila-db]# mysql

root@localhost[(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| scottdb            |
| tempdb             |
| test               |
+--------------------+
7 rows in set (0.01 sec)

root@localhost[(none)]> use sakila

Database changed

root@localhost[sakila]> show tables;
+----------------------------+
| Tables_in_sakila           |
+----------------------------+
| actor                      |
| actor_info                 |
| address                    |
| category                   |
| city                       |
| country                    |
| customer                   |
| customer_list              |
| film                       |
| film_actor                 |
| film_category              |
| film_list                  |
| film_text                  |
| inventory                  |
| language                   |
| nicer_but_slower_film_list |
| payment                    |
| rental                     |
| sales_by_film_category     |
| sales_by_store             |
| staff                      |
| staff_list                 |
| store                      |
+----------------------------+
23 rows in set (0.00 sec)

root@localhost[sakila]> select count(*) from customer;
+----------+
| count(*) |
+----------+
|      599 |
+----------+
1 row in set (0.01 sec)

更多参考:  http://dev.mysql.com/doc/sakila/en/sakila-installation.html 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SakilaMySQL官方提供的一个样例数据库,用于演示和练习MySQL数据库的使用。数据库包含了一个虚构的DVD租赁店的数据,其中包括客户、电影、租赁记录等等。 Sakila数据库包含16张表,包括: 1. `actor`:演员表,包含演员的ID、名字和最后更新时间。 2. `address`:地址表,包含地址的ID、地址、邮编、电话和最后更新时间。 3. `category`:电影类别表,包含类别的ID和名称以及最后更新时间。 4. `city`:城市表,包含城市的ID、城市名称、国家ID和最后更新时间。 5. `country`:国家表,包含国家的ID、国家名称和最后更新时间。 6. `customer`:客户表,包含客户的ID、姓名、地址、邮编、电话、积分、注释和最后更新时间。 7. `film`:电影表,包含电影的ID、标题、描述、发行年份、语言ID、原始语言ID、租金、长度、评级和最后更新时间。 8. `film_actor`:电影演员表,包含电影ID和演员ID。 9. `film_category`:电影类别表,包含电影ID和类别ID。 10. `inventory`:库存表,包含DVD的ID、电影ID和最后更新时间。 11. `language`:语言表,包含语言的ID、名称和最后更新时间。 12. `payment`:支付表,包含支付的ID、客户ID、租赁ID、支付时间、租赁时长和支付金额。 13. `rental`:租赁表,包含租赁的ID、客户ID、电影ID、租赁时间和最后更新时间。 14. `staff`:员工表,包含员工的ID、姓名、地址、邮编、电话、邮箱、店铺ID、用户名、密码和最后更新时间。 15. `store`:店铺表,包含店铺的ID、地址、邮编、电话和最后更新时间。 16. `sales_by_film_category`:按电影类别统计销售额的视图,包含类别名称和销售额。 使用Sakila数据库可以练习SQL查询、联结、聚合、子查询等等操作,是学习MySQL的很好的工具。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值