MySQL中创建table的流程
创建表;
create table stu(id int(5)auto_increment not null primary key comment'主键',name char(3) not null comment'姓名',
age int(2) not null comment '年龄')comment'学生姓名表';
查看创建表用的动作;
show create table stu;
向表内插入数据;
insert into stu(id,name,age) values(1001,'小明',18);
查看表的结构;查看表内的数据;
desc stu; select * from stu;
增加列;
alter table stu add phone char(11) not null fist(或after 字段名称);
删除列;
alter table stu drop phone;
delete from stu where id = '';
清除表内数据;
delete stu;/truncate stu;
更改字段的属性及设置;
alter table stu modify phone null;
设置及删除字段的默认值:
alter table stu alter phone set default = '18834561234';
alter table stu alter phone drop default;
挑选出符合条件的数据;
select id,name from stu where id = 1001;
select id from stu where name like '%明';
更新与更改行中的数据;
update stu set age = '19' where id = 1001;