当前位置:网站首页>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';
边栏推荐
- Super wow fast row, you are worth learning!
- Select sort and bubble sort
- [recruitment position] infrastructure software developer
- Temporary cramming before DFS examination
- 基于OpenHarmony的智能金属探测器
- Bugku alert
- keep-alive
- Detailed explanation of C language branch statements
- Install PHP extension spoole
- Bugku's Ping
猜你喜欢
P1451 calculate the number of cells / 1329: [example 8.2] cells
JS knowledge points-01
Au - delà du PARM! La maîtrise de l'Université de Pékin propose diverse pour actualiser complètement le classement du raisonnement du NLP
Common MySQL interview questions
Bugku cyberpunk
Appium自动化测试基础 — APPium基础操作API(二)
D-snow halo solution
Advanced level of static and extern
Value series solution report
Select sort and bubble sort
随机推荐
Install PHP extension spoole
【簡記】解决IDE golang 代碼飄紅報錯
数学建模之层次分析法(含MATLAB代码)
复现Thinkphp 2.x 任意代码执行漏洞
Example of lvgl display picture
No one consults when doing research and does not communicate with students. UNC assistant professor has a two-year history of teaching struggle
Ionic Cordova project modification plug-in
Cartoon: programmers don't repair computers!
DVWA range clearance tutorial
Hongmeng system -- Analysis from the perspective of business
Anti shake and throttling
Appium自动化测试基础 — APPium基础操作API(一)
JS bright blind your eyes date selector
亿咖通科技通过ISO27001与ISO21434安全管理体系认证
MySQL之CRUD
Common PHP interview questions (1) (written PHP interview questions)
1330: [example 8.3] minimum steps
Reasons and solutions for redis cache penetration and cache avalanche
Fr exercise topic --- comprehensive question
把 ”中台“ 的思想迁移到代码中去