如何使用mysql workbench怎么运行sql语句h

MySQL Workbench的使用教程
(初级入门版) - 海山 - 博客园
MySQL Workbench&是 MySQL AB 最近释放的可视数据库设计工具。这个工具是设计 MySQL 数据库的专用工具。
MySQL Workbench 拥有很多的功能和特性;这篇由Djoni Darmawikarta&写的文章通过一个示例展现了其中的一些。我们将针对一个订单系统建立一个物理数据模型,这里的订单系统可以是销售单也可以是订单,并且使用 &forward-engineer(正向引擎)&将我们的模型生成为一个 MySQL 数据库。
MySQL Workbench&是 MySQL 最近释放的可视数据库设计工具。这个工具是设计 MySQL 数据库的专用工具。
你在 MySQL Workbench 中建立的被称之为物理数据模型。一个物理数据模型是针对一个特定 RDBMS 产品的数据模型;本文中的模型将具有一些 MySQL 的独特规范。我们可以使用它生成(forward-engineer)数据库对象,除了包含表和列(字段)外,也可以包含视图。
MySQL Workbench 拥有很多的功能和特性;这篇由 Djoni Darmawikarta写的文章通过一个示例展现了其中的一些。我们将针对一个订单系统建立一个物理数据模型,这里的订单系统可以是销售单也可以是订单,并且使用 &forward-engineer(正向引擎)&将我们的模型生成为一个 MySQL 数据库。&
我们的示例中使用 MySQL Workbench 创建的物理模型看上去就像下图这样:
创建订单方案(ORDER Schema)
首先让我们来创建一个保存订单物理模型的方案。点击 + 按钮(红色标注的地方)
更改新的方案默认名称为订单。注意,当你键入方案名时,在 Physical Schemata 上的标签名也会随之改变&&这是一个很好的特性。
订单方案被增加到目录(Catalog)中 (图中红色圈住的部分)。
重命名方案后关闭 schema 窗口。
创建订单表
我们现在创建订单模型中的三个表:ORDER 表以及它的两个子表 SALES_ORDER 和PURCHASE_ORDER。首先,确信你已经选择了 ORDER 方案的标签,这样,我们创建的表才会包含于这个方案。
我们将要创建的表是作为 EER 图表展示的(EER = Enhanced Entity Relationship)。所以,双击 Add Diagram 按钮。
单击 Table 图标,然后移动鼠标到 EER Diagram 区域,在你想放置第一个表的位置上单击鼠标。
对于其他两个表,重复上面的操作。你可以通过拖拽来移动表的位置。
下一步,我们要对 table1 做一些操作,这些操作是通过 Workbench 的表编辑器完成的。要打开表编辑器,只需右键选择 table1 并选择 Edit Table 菜单。
键入 table1 的表名 ORDER 。
接下来,增加列(字段)。选择 Columns 标签。将列名(字段名) idORDER 更改为 &ORDER_NO.
在下拉列表框中选择数据类型 INT 。
我们希望 ORDER_NO 列的值可以被 MySQL 数据库自动控制,所以,我们选定 AI 列 (Auto Increment&&自增量).
AI 是 MySQL 数据库的一个特性。
你也可以指定表的其他物理属性,例如它的 Collation 属性;当然可以指定表的其他高级选项,例如 trigger 和 portioning (分别对应 Trigger 和 Partioning 标签)。
注意,这时,在 diagram 中我们表 table1 已经改变为 ORDER,并且,它有一个列(字段)ORDER_NO。在目录中,你也可以看到有三个表。
在表右侧的黑点,表示它们包含在一个图表中。
如果你展开 ORDER ,你可以看到 ORDER_NO 列。因为我们定义它为主键,所以在它左侧有一个 key 图标。
回到表设计器,增加其他两列(字段):ORDER_DATE 和 ORDER_TYPE。ORDER_TYPE 可以有两个值:S 表示销售订单,P 表示采购订单。由于销售订单是更常用的,所以我们指定列(字段)的默认值为 S 。
你可以在最后一列的下面白色区域双击鼠标来增加下一个字段。
使用同样的方式来创建 SALES_ORDER 表及其中的列(字段)。
最后,创建 PURCHASE_ORDER 表及其中的列(字段)。
我们已经创建了三个表。到这里并没有结束;我们仍旧需要创建它们的关系。
SALES_ORDER 是 ORDER 的子表,意味着它们是 1:1 ,SALES_ORDER 为子表, ORDER 为父表,并将 ORDER 的键移动到 SALES_ORDER 。所以,选择(单击)1:1 identifying relationship 图标,然后在 SALES_ORDER 表上单击,再在 ORDER 表上单击。
注意,当你在单击表时,图标将变为带有 1:1 关系的手型。
1:1 关系就是这样设置的;ORDER_NO 主键被移动到 SALES_ORDER 表并作为它的主键。
下一步,创建 PURCHASE_ORDER 到 ORDER 的关系,它仍旧是 1:1 关系。
我们现在已经完成了表及表之间关系的设计;将我们的模型保存为 ORDER.mwb.
生成 DDL 和数据库
最终在本文设计数据模型的目的是为了建立 MySQL 数据库。我们将首先生成 DDL(SQL CREATE script),然后执行这个脚本。
从&File | Export&菜单中,选择 Forward Engineer SQL CREATE Script.
最后,执行保存的 SQL CREATE 脚本。MySQL Workbench 自身并没有执行这个脚本的能力;我们可以在 MySQL 命令控制台中来执行它。
你也可以在其中来查看表是否已经被创建。
这篇文章向你展示了在 MySQL Workbench 中如何可视的建立 MySQL 物理数据模型,并使用它来创建一个 MySQL 数据库。5240人阅读
技术类(83)
要检查默认的启动/停止/状态检查命令是否是你设置的对应的mysql服务的名称 home/serveradmin/manage server instance
例如sc start mysql51 中mysql51 要对应实际的服务名称(不区分大小写)
MySQL Workbench&is a visual database design tool recently released by MySQL AB. The tool is specifically for designing MySQL database.
MySQL Workbench has many fu this article by&Djoni Darmawikarta&shows some of them by way of an example. We’ll build a physical data model for an order system where an order can be a sale order or a purchase order, and then,&forward-engineer&our
model into an MySQL database.
MySQL Workbench&is a visual database design tool recently released by MySQL AB. The tool is specifically for designing MySQL database.
What you build in MySQL Workbench is called physical data model. A physical data model is a data model for a specific RDBMS the model in this article will have some MySQL unique specifications. We can generate (forward-engineer) the
database objects from its physical model, which in addition to tables and their columns, can also include other objects such as view.
MySQL Workbench has many fu this article by&Djoni Darmawikarta&shows some of them by way of an example. We’ll build a physical data model for an order system where an order can be a sale order and then,&forward-engineer&our
model into an MySQL database.
The physical model of our example in EER diagram will look like in the following MySQL Workbench screenshot.
Creating ORDER Schema
Let’s first create a schema where we want to store our order physical model. Click the + button (circled in red).
Change the new schema’s default name to ORDER. Notice that when you’re typing in the schema name, its tab name on the Physical Schemata also changes accordingly—a nice feature.
The order schema is added to the Catalog (I circled the order schema and its objects in red).
Close the schema window. Confirm to rename the schema when prompted.
Creating Order Tables
We’ll now create three tables that model the order: ORDER table and its two subtype tables: SALES_ORDER and PURCHASE_ORDER, in the ORDER schema. First of all, make sure you select the ORDER schema tab, so that the tables we’ll create will be in this schema.
We’ll create our tables as EER diagram (EER = Enhanced Entity Relationship). So, double-click the Add Diagram button.
Select (click) the Table icon, and then move your mouse onto the EER Diagram canvas and click on the location you want to place the first table.
Repeat for the other two tables. You can move around the tables by dragging and dropping.
Next, we’ll work on table1, which we’ll do so using the Workbench’s table editor. We start the table editor by right-clicking the table1 and selecting Edit Table.
Next, we’ll work on table1, which we’ll do so using the Workbench’s table editor. We start the table editor by right-clicking the table1 and selecting Edit Table.
Rename the table by typing in ORDER over table1.
We’ll next add its columns, so select the Columns tab. Replace idORDER column name with ORDER_NO.
Select INT as the data type from the drop-down list.
We’d like this ORDER_NO column to be valued incrementally by MySQL database, so we specify it as AI column (Auto Increment).
AI is a specific feature of MySQL database.
You can also specify other physical attributes of the table, such as its C as well as other advanced options, such as its trigger and partioning (the Trigger and Partioning tabs).
Notice that on the diagram our table1 has changed to ORDER, and it has its first column, ORDER_NO. In the Catalog you can also see the three tables.
The black dots on the right of the tables indicate that they’ve been included in an diagram.
If you expand the ORDER folder, you’ll see the ORDER_NO column. As we define the column as a primary key, it has a key icon on its left.
Back to the table editor, add the other columns: ORDER_DATE and ORDER_TYPE. The ORDER_TYPE can have one of two values: S for sales order, P for purchase order. As sales order is more common, we’d like to specify it as the column’s default value.
You add the next column by double-clicking the white space below the last column.
In the same way, create the SALES_ORDER table and its columns.
Lastly, create the PURCHASE_ORDER table and its columns.
Create Relationships
We have now created all three tables and their columns. We haven’t don we still need to create the subtype relationships of our tables.
The SALES_ORDER is a subtype of ORDER, implying their relationship is 1:1 with the SALES_ORDER as the child and ORDER the parent, and also the ORDER’s key migrated to the SALES_ORDER. So, select (click) the 1:1 identifying relationship icon, and click it on
the SALES_ORDER table and then ORDER table.
Notice that the icon changes to a hand with the 1:1 relationship when you click it to the tables.
The 1:1 the ORDER_NO primary key is migrated and becomes the primary key of the SALES_ORDER table.
Next, create the PURCHASE_ORDER to ORDER relationship, which is also 1:1 identifying relationship.
We have now completed designing our tables and let’s save our model as ORDER.mwb.
Generate DDL and Database
The final step of our data modeling in this article is generating the model into MySQL database. We’ll first generate the DDL (SQL CREATE script), and then execute the script.
From the&File | Export&menu, select&Forward Engineer SQL CREATE Script.
Lastly, execute the saved SQL CREATE script. We execute the script outside of MySQL W for example, we can execute it in a MySQL command console.
You can also confirm that the tables have been created.
&MySQL Workbench 是mysql的建模工具,可以利用Workbench 创建数据库和表,然后导出为.sql的创建文件,拿到命令下可以直接执行
创建任务。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:249052次
积分:2779
积分:2779
排名:第9170名
原创:45篇
转载:56篇
评论:30条
(1)(2)(1)(4)(1)(5)(1)(1)(6)(1)(1)(2)(2)(3)(1)(1)(5)(7)(3)(5)(4)(1)(3)(4)(5)(6)(11)(14)[摘要: Workbench是可视化计划、治理的对象,它同时有开源战贸易化的两个版本。该硬件支撑战体系。 应当是GUI TOOLS的进级版。
往民网下载紧缩包,解压,]
MySQL Workbench是可视化数据库设计、管理的工具,它同时有开源和商业化的两个版本。该支持Windows和Linux系统。 应该是GUI TOOLS的升级版。
去官网下载压缩包,解压,找到Workbench.exe,打开。
启动mysql服务 点击Local instance MySQL &输入密码登录
登录后界面 输入测试语句,点击闪电图标,执行语句
QT5 第一章、windows下Qt5.0.2安装使用-空的Qt建立Helloworld
在visual studio 2012 环境下开发windows phone
怎么安装使用silverlight
for windows phoneTool
Wamp安装使用+Git for Windows
boost1.55 安装使用教程 windows
Ice安装使用方法----windows
vmware的安装使用 下载 注册
下安装使用vsFtp的步骤
win7 pycharm下 安装使用GPU 的theano
GSL 安装使用方法 MinGW 、 VC、Borland C++ Builder、Windows开发环境下的使用求教mac使用mysql和MySQL Workbench_macbook吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:270,897贴子:
求教mac使用mysql和MySQL Workbench收藏
本人学习java编程的,一直连接虚拟机上的oracle,感觉挺麻烦,想弄个mysql for mac使用,官网下了mysql和MySQL Workbench,用不来, 有哪位也是做程序的 可以教教我吗? 只要告诉我怎么建立连接,然后jdbc连上MySQL Workbench就好.扣扣
我会弄,后天回家教你吧,很简单的
你去下载for 10.6的mysql,可以装控制面板并且是dmg安装,比较方便也很简单,另外mysql装好后放在usr/local里面,所以终端开启mysql的时候要定位到那个文件夹,你创建的数据库都在那个文件夹里面
jdbc连接就自己看书吧,easy的
当然还要创建mysql的账户,初始root账户是没密码的最好设置一个
测试连接连不上
哦Workbench不是我想的那个,你是想用数据库管理软件?
我现在不在家啊→_→
port用3306!你设置的8080?哪个是web容器吧?
你开了mysql服务器了吗?在系统偏好设置里面,还有需要mysql-jdbc的驱动,在官网也有
有安卓的么?8G内存够么?纠结于865和293,要不要上16G呢?
连数据库服务器就行,别装本机上
一般都是xcode coredata读取
txt文件怎么导入mac版本的sql啊
真搞不懂MYSQL这种垃圾为什麼那麼多人用,就连FACEBOOK GOOGLE都用这种垃圾
楼主加我qq帮我解决一下吗,我最近也遇到这问题,我的qq
楼主现在知道了吗?能不能教教我啊,,谢谢
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或

我要回帖

更多关于 workbench怎么运行sql语句 的文章

 

随机推荐