当前位置:网站首页>这些不太会
这些不太会
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 ;
边栏推荐
- 有没有完全自主的国产化数据库技术
- Linear programming matlab
- Add one to non negative integers in the array
- Referenceerror: primordials is not defined error resolution
- Redis cluster deployment based on redis5
- Misc (eternal night), the preliminary competition of the innovation practice competition of the National College Students' information security competition
- 故障分析 | MySQL 耗尽主机内存一例分析
- Single instance mode of encapsulating PDO with PHP in spare time
- #PAT#day10
- How to read excel, PDF and JSON files in R language?
猜你喜欢
codeforces每日5題(均1700)-第六天
MySQL advanced notes
Solution: attributeerror: 'STR' object has no attribute 'decode‘
Misc (eternal night), the preliminary competition of the innovation practice competition of the National College Students' information security competition
Network Security Learning - Web vulnerabilities (Part 1)
RobotFramework入门(二)appUI自动化之app启动
My C language learning record (blue bridge) -- on the pointer
Fault analysis | analysis of an example of MySQL running out of host memory
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 22
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8
随机推荐
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 7
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 10
Follow the mouse's angle and keyboard events
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 14
GifCam v7.0 极简GIF动画录制工具中文单文件版
codeforces每日5题(均1700)-第六天
Déduisez la question d'aujourd'hui - 729. Mon emploi du temps I
Fault analysis | analysis of an example of MySQL running out of host memory
如何精准识别主数据?
【Unity3D】GUI控件
"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.5 automatic differentiation_ Learning thinking and exercise answers
2345文件粉碎,文件强力删除工具无捆绑纯净提取版
XSS challenges bypass the protection strategy for XSS injection
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19
How to accurately identify master data?
tcpdump: no suitable device found
故障分析 | MySQL 耗尽主机内存一例分析
js 正则过滤和增加富文本中图片前缀
Solution: attributeerror: 'STR' object has no attribute 'decode‘
2.12 simulation