[AppleScript] 纯文本查看 复制代码
#创建数据库
create database hm7 charset utf8;
use hm7;
#创建数据表
create table student(
id int ,
name varchar(10),
#设置年龄的默认值为 23 插入时没有信息 使用默认值填充
age tinyint not null default 23,
city varchar(10) ,
major varchar(16)
)charset =utf8 comment ="学生信息表";
#插入学生信息
insert into student values
(1,"轩辕笔直",18,'上海市',"全栈专业"),
(2,"慕容婉约",19,'北京市',"Java"),
(3,"欧阳帅帅",20,'三门峡',"大数据");
#添加手机号字段
alter table student add tel char(11) ;
#添加自我介绍字段
alter table student add intro text after city;
insert into student (id,name,age,city,major) values
(1,"欧阳我去",21,'上海市',"前端");
create table goods(
goods_id int primary key ,
goods_name varchar(20),
price float
);
insert into goods values (1,"华为nova",1234.9);
insert into goods values (1,"dell 燃7000",234.9);
alter table student modify id int primary key;
create table jd_goods(
goods_id int primary key auto_increment ,
goods_name varchar(20),
price float
);
insert into jd_goods (goods_name,price)values ("小米air",5999.9);
insert into jd_goods (goods_name,price)values ("锤子T2",2999.9);
#id字段已经是 主键
alter table student modify id int auto_increment;
insert into student (name,age,city,major) values
("欧阳我去",21,'上海市',"前端"),
("欧阳婷婷",23,'青岛市',"PHP"),
("慕容晓晓",17,'宁波市',"UI"),
("范冰冰",19,'大连市',"前端");