-- 创建三张表张表模拟银行存钱取钱,用户信息
-- 账户信息
create table t_user(account_id VARCHAR(32) PRIMARY KEY not null,username varchar(32) not null, sex char(2) not null, age int not null)
-- 余额表
create table account(account_id varchar(32) not null,money DECIMAL(10,2) not null)
-- 取钱表
create table orders(ord_id int PRIMARY key auto_increment not null,account_id varchar(32) not null ,ord_money DECIMAL(10,2) not null)
-- 给t_user表sex字段设置一个检查约束,约束条件为'男'or'女'
alter table t_user add CONSTRAINT check_1 CHECK(sex in('男','女'));
-- 删除约束
alter table t_user drop CHECK
-- 插入数据
INSERT into t_user values('20180201','曹煌雯','男',21)
INSERT into t_user values('20180202','leno','女',21)
INSERT into t_user values('20180203','zhq','男',23)
-- 删除数据
delete FROM t_user where account_id='20180201'
-- 查询数据
select*from t_user
-- 更新数据
update t_user set age=22 WHERE account_
SQL语句汇总
最新推荐文章于 2023-02-13 15:00:00 发布