当前位置:网站首页>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';
边栏推荐
- 2.3 learning content
- Common interview questions about swoole
- Install PHP extension spoole
- Severlet learning foundation
- JS topic - console log()
- Go language programming specification combing summary
- Leetcode: Shortest Word Distance II
- Huiyuan, 30, is going to have a new owner
- Reproduce ThinkPHP 2 X Arbitrary Code Execution Vulnerability
- ICML 2022 | 探索语言模型的最佳架构和训练方法
猜你喜欢
Select sort and bubble sort
Value series solution report
Usage and usage instructions of JDBC connection pool
Ionic Cordova project modification plug-in
F. Min cost string problem solving Report
超越PaLM!北大硕士提出DiVeRSe,全面刷新NLP推理排行榜
keep-alive
Appium自动化测试基础 — APPium基础操作API(二)
Transfer the idea of "Zhongtai" to the code
Write a go program with vscode in one article
随机推荐
I spring and autumn blasting-2
Redis distributed lock principle and its implementation with PHP (1)
Your childhood happiness was contracted by it
Huawei Hubble incarnation hard technology IPO harvester
Garbage collection mechanism of PHP (theoretical questions of PHP interview)
P1451 calculate the number of cells / 1329: [example 8.2] cells
Appium自动化测试基础 — APPium基础操作API(二)
Ecotone technology has passed ISO27001 and iso21434 safety management system certification
Severlet learning foundation
Bugku's Eval
Example of lvgl display picture
30岁汇源,要换新主人了
Leetcode: Shortest Word Distance II
1330: [example 8.3] minimum steps
MySQL 巨坑:update 更新慎用影响行数做判断!!!
sql server char nchar varchar和nvarchar的区别
Live broadcast preview | how to implement Devops with automatic tools (welfare at the end of the article)
CODING DevSecOps 助力金融企业跑出数字加速度
How can I quickly check whether there is an error after FreeSurfer runs Recon all—— Core command tail redirection
Linear DP (basic questions have been updated)