mysql+workbench的初步使用
最近工作需要学习SQL,查阅了相关知识购买了图书《SQL必知必会》第五版。这本书没有提供对应的软件,需要读者自行搭建环境。这里笔者选用mysql+workbench,这篇文章旨在搭建可以学习本书相关指令的环境并且导入附录A的样例表(Vendors、products、customers、orders、orderitems)。
一、安装mysql+workbench
按照 该文逐步操作安装mysql
下载并安装 workbench(如果连接挂了,请去官网找)
二、导入附录A的样例表
点进操作界面
操作界面如图所示,点击“schema”进入操作库界面,再点击“添加数据库”图标。
改好名字点击“apply”,一路确定即可创建空白数据库。(这里笔者采用姓名“tyqsl2”)

这里举例创建Customers表,在对应框里输入代码:
// An highlighted block
CREATE TABLE Customers
(
cust_id char(10) NOT NULL ,
cust_name char(50) NOT NULL ,
cust_address char(50) NULL ,
cust_city char(50) NULL ,
cust_state char(5) NULL ,
cust_zip char(10) NULL ,
cust_country char(50) NULL ,
cust_contact char(50) NULL ,
cust_email char(255) NULL
);
点击执行命令,即可创建customer表
再把代码删掉,输入下列代码,为customers表添加内容,并点击执行
// An highlighted block
INSERT INTO Customers(cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact, cust_email)
VALUES('1000000001', 'Village Toys', '200 Maple Lane', 'Detroit', 'MI', '44444', 'USA', 'John Smith', 'sales@villagetoys.com');
INSERT INTO Customers(cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact)
VALUES('1000000002', 'Kids Place', '333 South Lake Drive', 'Columbus', 'OH', '43333', 'USA', 'Michelle Green');
INSERT INTO Customers(cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact, cust_email)
VALUES('1000000003', 'Fun4All', '1 Sunny Place', 'Muncie', 'IN', '42222', 'USA', 'Jim Jones', 'jjones@fun4all.com');
INSERT INTO Customers(cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact, cust_email)
VALUES('1000000004', 'Fun4All', '829 Riverside Drive', 'Phoenix', 'AZ', '88888', 'USA', 'Denise L. Stephens', 'dstephens@fun4all.com');
INSERT INTO Customers(cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact)
VALUES('1000000005', 'The Toy Store', '4545 53rd Street', 'Chicago', 'IL', '54545', 'USA', 'Kim Howard');
点击如图按钮可以详细显示该表
可见,该按钮效果是和图中selcet语句是等价的,下面的仪表盘可以显示该表的具体内容,是和我们输入的内容吻合的。
剩下几个表的加入方法是相同的,这里给出笔者写好的数据库tyqsl2的备份,以供下载
百度网盘:https://pan.baidu.com/s/1SIQemeHTMQtt-2obbucKuA 提取码:9fcv
使用方法参考这篇 博文
需要注意的是,要使用我配置的库,必须要和我的名字一样(tyqsl2).
版权声明:本文为GrandPandababy原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。