SQL不区分大小写
创建数据库
– 创建数据库
CREATE DATABASE db1;
– 查询数据库
SHOW DATABASES;
– 修改数据库
ALTER DATABASE db1 CHARACTER SET utf8;
– 删除数据库
drop DATABASE db1;
创建数据表
– 创建数据表 comment给列添加注释,在设计表中查看
create table goods2(
id varchar(128) not null comment '商品编号,不能为空,主键',
gname varchar(9) not null comment '商品名称',
stock int(5) not null default 0 comment '库存',
parchaseprice double(8,2) not null default 0.00,
sellprice double(8,2) not null default 0.00,
picture varchar(128) comment '商品图片',
primary key(id)
);
修改数据表
– timestamp 时间戳(yyyy-mm-dd hh:mi:ss)占4字节 常用
– datetime 日期时间(yyyy-mm-dd hh:mi:ss)占8字节
– date 日期(yyyy-mm-dd)
– current_timestamp 系统函数,获取当前系统时间
-- 新增一列
alter table goods2 add column feature varchar(256) comment '商品描述';
alter table goods2 add column shelfTime timestamp not null default
current_timestamp on update current_timestamp comment'商品上架时间';
-- 删除列abc
alter table goods drop column abc;
```![在这里插入图片描述](https://img-blog.csdnimg.cn/20190715203113287.png)