当前位置:网站首页>MySQL advanced (thirty-three) MySQL data table adding fields
MySQL advanced (thirty-three) MySQL data table adding fields
2022-08-10 14:24:00 【InfoQ】
一、在末尾添加字段
ALTER TABLE <表名> ADD <新字段名><数据类型>[约束条件];
- <表名> 为数据表的名字;
- <新字段名> 为所要添加的字段的名字;
- <数据类型> 为所要添加的字段能存储数据的数据类型;
- [约束条件] 是可选的,用来对添加的字段进行约束.
USE test;
CREATE TABLE student (
id INT(4),
name VARCHAR(20),
sex CHAR(1));
ALTER TABLE
ALTER TABLE student ADD age INT(4);
DESC student;
二、在开头添加字段
ALTER TABLE <表名> ADD <新字段名> <数据类型> [约束条件] FIRST;
ALTER TABLE
ALTER TABLE student ADD stuId INT(4) FIRST;
DESC student;
三、在中间位置添加字段
ALTER TABLE <表名> ADD <新字段名> <数据类型> [约束条件] AFTER <已经存在的字段名>;
ALTER TABLE student ADD stuno INT(11) AFTER name;
DESC student;
边栏推荐
猜你喜欢
从洞察到决策,一文解读标签画像体系建设方法论
符合信创要求的堡垒机有哪些?支持哪些系统?
网络安全——XSS之被我们忽视的Cookie
关于已拦截跨源请求CORS 头缺少 ‘Access-Control-Allow-Origin‘问题解决
Send a post request at the front desk can't get the data
Error: Rule can only have one resource source (provided resource and test + include + exclude)
Alibaba的秒杀系统—千亿级并发设计手册上线了
MySQL - storage engine for databases
How does IT Xiaobai learn PHP systematically
R语言实战应用案例:论文篇(一)-特殊柱形图绘制
随机推荐
Fragment's show and hide
vue 怎么清除tab 切换缓存问题 ?
OpenStack-related commands that need to be recorded _ self-use
【量化交易行情不够快?】一文搞定通过Win10 wsl2 +Ubuntu+redis+pickle实现股票行情极速读写
系统的安全和应用(不会点安全的东西你怎么睡得着?)
电脑重装系统提示activex部件不能创建对象如何解决
安装mysql报错处理
2022-08-10日报: Swin Transformer作者曹越加入智源,开展视觉基础模型研究
Short read or OOM loading DB. Unrecoverable error, aborting now
第三方软件测评有什么作用?权威软件检测机构推荐
每个月工资表在数据库如何存储?求一个设计思路
Makefile missing separator. Stop.怎么解决「建议收藏」
malloc 函数详解
等保2.0一个中心三重防护指的是什么?如何理解?
Send a post request at the front desk can't get the data
发送post请求前台无法获取数据
[219] The training course notes of the go engineer with more than 3,000 MOOCs 02 Programming ideas in the go language
The recursive recursive Fighting_ silver study ah but level 4
高数_证明_曲率公式
[Gazebo Introductory Tutorial] Lecture 3 Static/Dynamic Programming Modeling of SDF Files