将数据和架构导入MySQL Workbench [英] Importing Data and Schema to MySQL Workbench

查看:118
本文介绍了将数据和架构导入MySQL Workbench的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习SQL,我下载了一个数据库进行练习.我下载了两个扩展名为.sql的文件,一个是架构,另一个是实际数据.我还安装了MySQL Workbench.我一直在使用Google搜索,并且一直在尝试解决问题的方法,但是我不了解Workbench,也无法加载数据库.

I'm trying to learn SQL and I downloaded a database to practice. I downloaded two files of extension .sql, one is the schema and the other one the actual data. I've also installed MySQL Workbench. I've been googling and I've been trying things to solve this but I don't understand Workbench and I can't load the database.

在哪里导入架构和数据以尝试查询?

Where do I import the schema and the data in order to try queries ?

任何帮助将不胜感激.

推荐答案

在Workbench中这很简单,我将以免费提供的sakila数据库为例.随意将其应用于您的情况:

This is simple in Workbench, and I'll use the freely available sakila database as an example. Feel free to apply this to your situation:

  1. 从此处下载"sakila": http://dev.mysql.com/doc /index-other.html
  2. 在我的情况下,将其提取到桌面上的某个位置,进入新的sakila-db/目录
  3. 打开工作台
  4. 在模式浏览器"中,右键单击空白区域,然后选择创建模式"
  5. 在架构创建向导中,将其命名为"sakila",保留默认值,单击"Apply",完成向导
  6. 转到文件"->运行SQL脚本..."
  7. 选择"sakila-schema.sql",确保默认架构名称"为空,或选择"sakila",执行
  8. 转到文件"->运行SQL脚本..."
  9. 选择"sakila-data.sql",执行
  10. 在Workbench架构导航器中单击刷新"图标(或重新启动Workbench)
  11. 现在,使用填充的sakila数据库:)
  1. Download "sakila" from here: http://dev.mysql.com/doc/index-other.html
  2. Extract it somewhere, in my case, onto the Desktop into a new sakila-db/ directory
  3. Open Workbench
  4. In the Schema Navigator, right-click an empty area and choose "Create Schema"
  5. In the schema creation wizard, name it "sakila", keep the defaults, hit "Apply", finish wizard
  6. Go to "File" -> "Run SQL Script..."
  7. Choose "sakila-schema.sql", make sure "Default Schema Name" is blank or select "sakila", execute
  8. Go to "File" -> "Run SQL Script..."
  9. Choose "sakila-data.sql", execute
  10. Click the "refresh" icon in the Workbench Schema Navigator (or restart Workbench)
  11. Now, use the populated sakila database :)

在这种情况下,步骤(4)和(5)是可选的(因为执行sakila-schema.sql创建模式),但是这个想法值得一提.

Steps (4) and (5) are optional in this case (as executing sakila-schema.sql creates the schema), but the idea is worth mentioning.

将脚本加载到SQL IDE时的外观如下:

Here's how it would look when loading th script into the SQL IDE:

这篇关于将数据和架构导入MySQL Workbench的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆