mysql增删改差

增加

create database ab1 charset utf-8;

show databases;

show create database db1;

alter database db1 charset gbk;

drop database db1;

 

 

操作表(文件)

切换到某一个库(文件)

use db1;

select database();查看当前所在的库

create table ti(id int,name char(10),age int)egine=innodb default charset utf-8;

最后一个字段不要加逗号

show tables;

show create table t1;

desc t1 查看表结构

alter table t1 charset gbk;

alter table ti add sex char;

alter table t1 drop sex;

alter table t1 modify sex char(6);

alter table t1 change sex Sex char (6);

删除

drop table table66;

操作纪律

增加

insert into db1.t1(id,name,age, Sex) values

(1,'egon',18,'male'),

(2,'egon2',28,'male'),

(3,'egon3',38,'male'),

(4,'egon4',48,'male');

insert intodb1.t1(id,name)values(5,'egon5');

select name id from db1.t1;

select*from db1.t1;

update db1.t1 set name='EGON4';

update db1.t1 set name='alexsb' where id=5;

update db1.t1 set name='aaa' where Sex='male';

delete from db1.t1 JI仅删除纪律效果,没有吧表重置到初始状态的功能

truncate db1.t1; 清空加重置

delete from db1.t1 where id=3;

delete feom db1.t1 where name='ddd';

自增id

create table t1(id int not null unique auto_increment,name chaer(4));

自增的字段必须是

insert into db1.t1(name) values

('egon1'),

('egon2'),

('egon3'),

('egon4');

posted @ 2017-10-20 17:51  程绩  阅读(246)  评论(0编辑  收藏  举报