/*
create/select/insert/update/where
*/
create//创建数据库、表、存储过程、视图等
select//读取一条或者多条记录/*创建数据库*/
create database test; /*创建users表*/create table if not exists users(id int not null auto_increment,name varchar(50) not null,gender varchar(2) not null,birthday date not null,address varchar(100) not null,telephone varchar(11) not null,primary key(id))engine=innodb default charset=utf8;//engine表示用innodb引擎,默认字符为utf8 /*创建ck存储过程*/delimiter $create procedure if not exists ck()beginselect * from users;end $delimiter ;insert//insert into插入数据
insert into users(id,name,gender,birthday,address,telephone) values (1,"高某","男","1981-11-05","北京","15809320031");
insert into users(name,gender,birthday,address,telephone) values ("罗某","女","1984-01-15","北京","15800310933");insert into users(name,gender,birthday,address,telephone) values ("张某","女","1994-05-01","北京","15899432158");insert into users(name,gender,birthday,address,telephone) values ("曹某","女","1995-08-19","北京","17803318972");insert into users values(5,'唐某','1994-10-01','甘肃','13756024455');update//更新一个或多个字段
update users set address="甘肃",telephone="17103318972" where id=4;
alter//添加、删除或修改字段
alter table users modify name varchar(25);
like//LIKE 子句与等号 = 的效果是一样的,SQL LIKE 子句中使用百分号 %字符来表示任意字符。
select * from users where telephone like "158%";