SQL基本操作

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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值