乌班图中输入: mysql -uroot -p
1.创建一个数据库 jing_dong
create database jing_dong
2.创建一个数据表goods
create table goods(
id int unsigned primary key auto_increment not null,
name varchar(150) not null,
cate_name varchar(40) not null,
brand_name varchar(40) not null,
price decimal(10,3) not null default 0,
is_show bit not null default 1,
is_saleoff bit not null default 0
);
2.数据表中插入数据
insert into goods values(0,'r510vc 15.6英寸笔记本','笔记本','华硕','3399',default,default);
insert into goods values(0,'y400n 14.0英寸笔记本电脑','笔记本','联想','4999',default,default);
insert into goods values(0,'g150th 15.6英寸游戏本','游戏本','雷神','8499'<

这篇博客介绍了如何在Ubuntu上通过Python操作MySQL进行数据表拆分。首先创建数据库和原始数据表,然后根据cate_name创建新的商品种类表。接着,将数据分组并同步到新表,确保数据类型一致。最后,在原始表中添加外键,与新表的主键关联,以实现数据的完整性。

1360

被折叠的 条评论
为什么被折叠?



