创建数据库
1 |
create database db; |
创建用户
1 |
create user 'aa'@'127.0.0.1' identified by '1234'; |
用户授权
1 |
grant all privileges on db.* to 'aa'@'127.0.0.1' with grant option; |
创建表(设置主键,自动编码)
1 |
create table cj(id int not null primary key auto_increment,xm char(4) not null,nl int not null); |
插入数据
1 |
insert into cj values('','sdfd',19); |
修改数据
1 |
update cj set xm='fdd' where id =1; |
删除数据
1 |
delete from cj where id =1; |
删除自动编码
1 |
alter table cj modify id int not null; |
删除主键
1 |
alter table cj drop primary key; |
添加主键
1 |
alter table cj add primary key(id); |
添加自动编码
1 |
alter table cj change id id int auto_increment; |
删除用户
1 |
drop user 'aa'@'127.0.0.1'; |
删除数据库
1 |
drop database db; |
二〇一五年四月一日 10:54:12