mysql 基础命令(一)

创建数据库

create database db;

创建用户

create user 'aa'@'127.0.0.1' identified by '1234';

用户授权

grant all privileges on db.* to 'aa'@'127.0.0.1' with grant option;

创建表(设置主键,自动编码)

create table cj(id int not null primary key auto_increment,xm char(4) not null,nl int not null);

插入数据

insert into cj values('','sdfd',19);

修改数据

update cj set xm='fdd' where id =1;

删除数据

delete from cj where id =1;

删除自动编码

alter table cj modify  id int not null;

删除主键

alter table cj drop primary key;

添加主键

alter table cj add primary key(id);

添加自动编码

alter table cj change id id int auto_increment;

删除用户

drop user 'aa'@'127.0.0.1';

删除数据库

drop database db;

 

 

 

二〇一五年四月一日 10:54:12

点赞