Step1: 下载 Sakila数据库

参考网址: https://blog.csdn.net/geekcoder/article/details/8988052

下载地址:https://dev.mysql.com/doc/index-other.html

kettle(五):下载 Sakila数据库

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;

 

解决方法:

  1. 手动打开sakila-data.sql文件;
  2. 搜索其中导入film数据的SQL语句;

kettle(五):下载 Sakila数据库

  1. 拷贝出这些sql语句,到DBeaver中重新执行;

kettle(五):下载 Sakila数据库

kettle(五):下载 Sakila数据库

kettle(五):下载 Sakila数据库

 

kettle(五):下载 Sakila数据库

 

按照上面的步骤拷贝SQL到DBeaver中运行,仍然发现这些插入SQL语句没有执行。

kettle(五):下载 Sakila数据库

为了反映错误,去掉set autocommit=0,再次执行;

kettle(五):下载 Sakila数据库

 

这是反映了错误信息如下:

kettle(五):下载 Sakila数据库

因为film的结构中差一个 film_text字段;

修改film的结构;

      重新导入数据即成功。

相关文章:

  • 2021-12-19
  • 2021-11-15
  • 2021-10-04
  • 2021-12-18
  • 2021-07-05
  • 2021-08-01
  • 2021-10-19
猜你喜欢
  • 2021-10-22
  • 2021-04-18
  • 2021-08-12
  • 2021-09-04
  • 2021-06-02
  • 2021-08-14
  • 2021-10-16
相关资源
相似解决方案