Step1: 下载 Sakila数据库
参考网址: https://blog.youkuaiyun.com/geekcoder/article/details/8988052
下载地址:https://dev.mysql.com/doc/index-other.html
Step2: MySQL中导入Sakila
To install the Sakila sample database, follow these steps:
1. Extract the installation archive to a temporary locationsuch as D:\ 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 d:/sakila-db/sakila-schema.sql;
Replace d:/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 D:/sakila-db/sakila-data.sql;
Replace d: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.mysql> SHOW TABLES;
12.mysql> SELECT COUNT(*) FROM film;
13.mysql> SELECT COUNT(*) FROM film_text;
发现错误:
Select count(*) from film
发现film表的数据为0;
解决方法:
- 手动打开sakila-data.sql文件;
- 搜索其中导入film数据的SQL语句;
- 拷贝出这些sql语句,到DBeaver中重新执行;
按照上面的步骤拷贝SQL到DBeaver中运行,仍然发现这些插入SQL语句没有执行。
为了反映错误,去掉set autocommit=0,再次执行;
这是反映了错误信息如下:
因为film的结构中差一个 film_text字段;
修改film的结构;
重新导入数据即成功。