当前位置:网站首页>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';
边栏推荐
- ICML 2022 | explore the best architecture and training method of language model
- Number protection AXB function! (essence)
- MySQL之CRUD
- 市值蒸发超百亿美元,“全球IoT云平台第一股”赴港求生
- What are the domestic formal futures company platforms in 2022? How about founder metaphase? Is it safe and reliable?
- Reasons and solutions for redis cache penetration and cache avalanche
- Install PHP extension spoole
- Appium自动化测试基础 — APPium基础操作API(一)
- I spring and autumn blasting-1
- Summary of the second lesson
猜你喜欢

Stop B makes short videos, learns Tiktok to die, learns YouTube to live?

"Sequelae" of the withdrawal of community group purchase from the city

Appium自动化测试基础 — APPium基础操作API(二)

Explanation report of the explosion

Bugku alert

亿咖通科技通过ISO27001与ISO21434安全管理体系认证

Thymeleaf uses background custom tool classes to process text

MySQL 巨坑:update 更新慎用影响行数做判断!!!

【 note 】 résoudre l'erreur de code IDE golang

lv_ font_ Conv offline conversion
随机推荐
First PR notes
I spring web upload
一文搞定vscode编写go程序
Explanation report of the explosion
F. Min cost string problem solving Report
Cartoon: what are the attributes of a good programmer?
MySQL5.7的JSON基本操作
D-snow halo solution
P1451 求细胞数量/1329:【例8.2】细胞
Crud of MySQL
Appium自动化测试基础 — APPium基础操作API(二)
MySQL之CRUD
OSI 七层模型
"Sequelae" of the withdrawal of community group purchase from the city
B站做短视频,学抖音死,学YouTube生?
Temporary cramming before DFS examination
复现Thinkphp 2.x 任意代码执行漏洞
JS bright blind your eyes date selector
Leetcode: Shortest Word Distance II
R 熵权法计算权重及综合得分