当前位置:网站首页>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';
边栏推荐
- Ctfshow web entry explosion
- Can I pass the PMP Exam in 20 days?
- How to introduce devsecops into enterprises?
- Surpass palm! Peking University Master proposed diverse to comprehensively refresh the NLP reasoning ranking
- I spring and autumn blasting-1
- Nine hours, nine people, nine doors problem solving Report
- D-snow halo solution
- MySQL----函数
- Example of lvgl display picture
- [brief notes] solve the problem of IDE golang code red and error reporting
猜你喜欢

CSRF, XSS science popularization and defense

Ten billion massage machine blue ocean, difficult to be a giant

Super wow fast row, you are worth learning!

Advanced level of static and extern

qt creater断点调试程序详解

D-snow halo solution

Crud of MySQL

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

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

Summary of the second lesson
随机推荐
Thymeleaf uses background custom tool classes to process text
Bugku's steganography
OSI 七层模型
华为哈勃化身硬科技IPO收割机
Detailed explanation of QT creator breakpoint debugger
爱可可AI前沿推介(7.5)
First PR notes
Optional parameters in the for loop
30岁汇源,要换新主人了
ionic cordova项目修改插件
Select sort and bubble sort
Linear DP (basic questions have been updated)
String modification problem solving Report
MySQL之CRUD
Hongmeng system -- Analysis from the perspective of business
I spring web upload
一文搞定vscode编写go程序
Reasons and solutions for redis cache penetration and cache avalanche
JS bright blind your eyes date selector
queryRunner. Query method