当前位置:网站首页>这些不太会
这些不太会
2022-07-06 02:57:00 【大厂全栈】
/* 修改表结构 修改表添加列 alter table 表名 add列名 类型(长度)[约束]; 练习: 为分类表添加一个新的字段为 分类描述 desc varchar(20) */ alter table category add `desc` varchar(20); /* 修改表修改列的类型长度及约束 alter table 表名 modify 列名 新的类型(长度) [约束]; 练习: 为分类表的描述字段进行修改,类型varchar(50) 添加约束 not null */ alter table category modify `desc` varchar(50) not null; /* 修改表修改列名 alter table 表名 change 旧列名 新列名 类型(长度) [约束]; 练习: 为分类表的分类描述字段进行更换 更换为 description varchar(30) */ alter table category change `desc` description varchar(30); /* 修改表删除列 alter table 表名 drop 列名; 练习: 删除分类表中description这列 */ alter table category drop description; /* 修改表名 rename table 旧表名 to 新表名; 练习: 为分类表category 改名成 c */ rename table category to c; rename table c to category; alter table db1.category rename to c; alter table c rename to category;
-- 模拟李四给张三转500元 -- 1.查看李四的账户余额 -- 不修改数据,和事务无关 -- 开启事务 begin ; -- 2.李四账户-500元 update account set money = money - 500 where name = '李四'; -- 出错了.... -- 3.张三账户+500元 update account set money = money + 500 where name = '张三'; -- 提交事务 commit ; -- 回滚事务 rollback ; -- 查看事务的默认提交方式 select @@autocommit; -- 1 自动提交 0 手动提交 -- 修改事务提交方式 set @@autocommit = 0; select * from account; update account set money = money - 500 where name = '李四'; -- 回滚事务 rollback ; -- 提交事务 commit ;
边栏推荐
- Apt installation ZABBIX
- Is there a completely independent localization database technology
- CSP numeric sort
- Zhang Lijun: penetrating uncertainty depends on four "invariants"
- js 正则过滤和增加富文本中图片前缀
- [matlab] access of variables and files
- Game theory matlab
- [ruoyi] ztree custom icon (iconskin attribute)
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24
- Jenkins basic knowledge ----- detailed explanation of 03pipeline code
猜你喜欢

Apt installation ZABBIX

Introduction to robotframework (III) Baidu search of webui automation

【指针训练——八道题】
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21](/img/73/4050a592fdd99bf06e8fd853b157b6.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 6](/img/38/51797fcdb57159b48d0e0a72eeb580.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 6

My C language learning records (blue bridge) -- files and file input and output

不赚钱的科大讯飞,投资价值该怎么看?

#PAT#day10

深度解析链动2+1模式,颠覆传统卖货思维?

Jenkins basic knowledge ----- detailed explanation of 03pipeline code
随机推荐
Software design principles
Misc (eternal night), the preliminary competition of the innovation practice competition of the National College Students' information security competition
Codeworks 5 questions per day (1700 average) - day 6
Era5 reanalysis data download strategy
纯Qt版中国象棋:实现双人对战、人机对战及网络对战
力扣今日題-729. 我的日程安排錶 I
Pat 1046 shortest distance (20 points) simulation
主数据管理理论与实践
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
Function knowledge points
tcpdump: no suitable device found
[unity3d] GUI control
I sorted out a classic interview question for my job hopping friends
2345文件粉碎,文件强力删除工具无捆绑纯净提取版
Pure QT version of Chinese chess: realize two-man, man-machine and network games
Solve 9 with C language × 9 Sudoku (personal test available) (thinking analysis)
ReferenceError: primordials is not defined错误解决
Redis installation
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 11