当前位置:网站首页>MySQL table field adjustment
MySQL table field adjustment
2022-07-05 15:30:00 【A green dragon bay moon knife】
New field format :
ALTER TABLE Table name ADD Field name Field type ( Field length - optional ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL( Can't be empty ) DEFAULT 0( The default value is ) COMMENT ' remarks ' AFTER After specifying the field ( No default last );
New examples :
ALTER TABLE table_name ADD COLUMN age varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 0 COMMENT ' Age ' AFTER name;
Modify field format :
ALTER TABLE table_name MODIFY COLUMN Field name New data types New type length New default New notes ;
-- COLUMN Keywords can be omitted
Modify field example :
ALTER TABLE table_name MODIFY COLUMN 'column' decimal (15,2) DEFAULT NULL COMMENT ' notes '; -- normal , Can modify the field type 、 Type length 、 The default value is 、 notes
Change the field type to unsigned :
ALTER TABLE table_name MODIFY COLUMN 'column' BIGINT(11) UNSIGNED DEFAULT '0' COMMENT ' notes ';
ALTER TABLE Table name CHANGE [column] Old field name new field name New data types ;
alter table table_name change old_column new_column varchar(100) DEFAULT '1.2' COMMENT ' notes '; -- normal , At this time, the field name has not changed , Can modify the field type 、 Type length 、 The default value is 、 notes
Modify table defaults If there is a default value, delete it first and then modify it
alter table table_name alter column column drop default;
alter table table_name alter column column set default '0';
边栏推荐
- lv_ font_ Conv offline conversion
- MySQL之CRUD
- 爱可可AI前沿推介(7.5)
- Array sorting num ranking merge in ascending order
- JS bright blind your eyes date selector
- F. Weights assignment for tree edges problem solving Report
- Ecotone technology has passed ISO27001 and iso21434 safety management system certification
- The elimination strategy of redis
- 社区团购撤城“后遗症”
- 【简记】解决IDE golang 代码飘红报错
猜你喜欢
Fr exercise topic - simple question
I include of spring and Autumn
Common MySQL interview questions
Bugku's eyes are not real
一文搞定vscode编写go程序
JS knowledge points-01
Write a go program with vscode in one article
B站做短视频,学抖音死,学YouTube生?
D-snow halo solution
Nine hours, nine people, nine doors problem solving Report
随机推荐
Bugku's eyes are not real
Your childhood happiness was contracted by it
Bugku alert
MySQL表字段调整
超越PaLM!北大硕士提出DiVeRSe,全面刷新NLP推理排行榜
ionic cordova项目修改插件
Install PHP extension spoole
Select sort and bubble sort
P6183 [USACO10MAR] The Rock Game S
你童年的快乐,都是被它承包了
数据库学习——数据库安全性
Can gbase 8A view the location of SQL statement history?
Anti shake and throttling
qt creater断点调试程序详解
Object. defineProperty() - VS - new Proxy()
Live broadcast preview | how to implement Devops with automatic tools (welfare at the end of the article)
PHP high concurrency and large traffic solution (PHP interview theory question)
【简记】解决IDE golang 代码飘红报错
I spring and autumn blasting-1
Array sorting num ranking merge in ascending order