创建数据库
CREATE DATABASE if not exists test_zzl
DEFAULT CHARACTER set utf8
DEFAULT COLLATE utf8_general_ci;
查看有多少数据库
SHOW DATABASES
切换数据库
use 表名
新建表
create table test_zzl(
id bigint auto_increment comment 'id',
name varchar(10) not null comment '姓名',
age int(3) not null comment '年龄',
primary key(id) #主键
)engine=InnoDB default charset =utf8 comment '测试表';
查看当前使用的数据库
select database()
查询当前数据库中所有表
show tables
查询
select * from table
新增
insert into table values(值1,值2,值3,……);
insert into table values(值1,值2,值3,……),(值1,值2,值3,……);
insert into table (字段1,字段2,字段3,……)values(值1,值2,值3,……);
insert into table (字段1,字段2,字段3,……)values(值1,值2,值3,……),(值1,值2,值3,……);
修改字段默认值
alter table dj_user alter column user_tx set default '';
截取最后一个-的后面所有的值
REVERSE(left(REVERSE('vip_cc_99123123'),LOCATE('_',REVERSE('vip_cc_99123123'))-1))