godfather 2020-06-13
创建数据库,创建表
create database test; create table user( id int not null primary key, name varchar(32) not null, password varchar(32) not null);
可以用desc查看创建的表的结构
desc user;
alter添加字段
alter table user add sex int;
insert into添加数据
insert into user (id,name,password) values (001,‘a‘,‘123‘), (002,‘b‘,‘qwe‘), (003,‘c‘,‘zxc‘);
delete删除数据
delete from user where id=003; #删除指定行 delete from user; #删除表
alter删除字段
alter table user drop sex;
alter修改字段
alter table usermodify password int;
update修改数据
update user set name=‘xiaoming‘,password=‘123456‘ where id=001;