当前位置:网站首页>mysql进阶(三十三)MySQL数据表添加字段
mysql进阶(三十三)MySQL数据表添加字段
2022-08-10 14:01:00 【InfoQ】
一、在末尾添加字段
ALTER TABLE <表名> ADD <新字段名><数据类型>[约束条件];
- <表名> 为数据表的名字;
- <新字段名> 为所要添加的字段的名字;
- <数据类型> 为所要添加的字段能存储数据的数据类型;
- [约束条件] 是可选的,用来对添加的字段进行约束。
USE test;CREATE TABLE student (
id INT(4),
name VARCHAR(20),
sex CHAR(1));
ALTER TABLEALTER TABLE student ADD age INT(4);DESC student;二、在开头添加字段
ALTER TABLE <表名> ADD <新字段名> <数据类型> [约束条件] FIRST;
ALTER TABLEALTER TABLE student ADD stuId INT(4) FIRST;DESC student;三、在中间位置添加字段
ALTER TABLE <表名> ADD <新字段名> <数据类型> [约束条件] AFTER <已经存在的字段名>;
ALTER TABLE student ADD stuno INT(11) AFTER name;DESC student;边栏推荐
- ICML 2022 | 基于随机注意力机制的可解释可泛化图学习
- SenseTime self-developed robotic arm, the first product is an AI chess-playing robot: Guo Jingjing is also invited as an endorsement
- 雨水中存在的PFAS化学物质对饮用水安全构成了威胁
- In the second half of 2012 system architecture designers afternoon paper II
- 统信 UOS V20 专业版(1050update2)发布:文件共享、全局搜索等优化
- R语言实战应用案例:论文篇(一)-特殊柱形图绘制
- Interface Automation Testing Basics
- “Oracle 封禁了我的账户”
- MySQL面试题整理
- 使用mysq语句操作数据库
猜你喜欢

借数据智能,亚马逊云科技助力企业打造品牌内生增长力

【ECCV 2022|Millions of Prizes】PSG Competition: Pursuing the "Most Comprehensive" Scene Understanding

开源SPL消灭数以万计的数据库中间表
![[Study Notes] Persistence of Redis](/img/e4/d3c09754ca5ac4fdad2653ccca6d82.png)
[Study Notes] Persistence of Redis

Using data intelligence, Amazon cloud technology helps companies build endogenous brand growth

R语言实战应用案例:论文篇(一)-特殊柱形图绘制

普林斯顿微积分读本05第四章--求解多项式的极限问题
![[JS Advanced] Creating sub-objects and replacing this_10 in ES5 standard specification](/img/3e/14a1d7c2837c896eaa0ca625eaa040.png)
[JS Advanced] Creating sub-objects and replacing this_10 in ES5 standard specification

统信 UOS V20 专业版(1050update2)发布:文件共享、全局搜索等优化

How does IT Xiaobai learn PHP systematically
随机推荐
C#报错 The ‘xmins‘ attribute is not supported in this context
这一次,话筒给你:向自由软件之父斯托曼 提问啦!
Classifying irises using decision trees
Matlab画分段函数「建议收藏」
[JS Advanced] Creating sub-objects and replacing this_10 in ES5 standard specification
使用mysq语句操作数据库
力扣解法汇总640-求解方程
学习日记9
tampercfg内核模块导致机器频繁crash
图式图例规范尺寸
Interface Automation Testing Basics
面试面到了一个腾讯30k出来的,有见识到何为精通MySQL调优
1W字详解线程本地存储 ThreadLocal
【MinIO】工具类使用
【ECCV 2022|百万奖金】PSG大赛:追求“最全面”的场景理解
In the second half of 2012 system architecture designers afternoon paper II
WebView的优化与常见问题解决方案
ABAP file operations involved in the Chinese character set of problems and solutions for trying to read
[target detection] small script: extract training set images and labels and update the index
Short read or OOM loading DB. Unrecoverable error, aborting now