当前位置:网站首页>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 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;
边栏推荐
- AWS Security Fundamentals
- 正则表达式(包含各种括号,echo,正则三剑客以及各种正则工具)
- R语言使用gt包和gtExtras包优雅地、漂亮地显示表格数据:gtExtras包的gt_highlight_rows函数高亮(highlight)表格中特定的数据行、配置高亮行的特定数据列数据加粗
- MySQL interview questions
- PEST 分析法
- ICML 2022 | 基于随机注意力机制的可解释可泛化图学习
- 这一次,话筒给你:向自由软件之父斯托曼 提问啦!
- 指针(C语言初解)
- 池化技术有多牛?来,告诉你阿里的Druid为啥如此牛逼!
- Import other custom namespaces in C#
猜你喜欢
Matrix Keyboard & Calculator Small Project Based on 51 (UcosII)
高数_证明_曲率公式
Existing in the rain of PFAS chemical poses a threat to the safety of drinking water
laravel throws the error to Dingding
Redis上云迁移实践
矩阵键盘&基于51(UcosII)计算器小项目
How does IT Xiaobai learn PHP systematically
[Gazebo Introductory Tutorial] Lecture 3 Static/Dynamic Programming Modeling of SDF Files
普林斯顿微积分读本05第四章--求解多项式的极限问题
【目标检测】小脚本:提取训练集图片与标签并更新索引
随机推荐
awk的简单使用
data product manager
指针(C语言初解)
malloc 函数详解
2011年下半年 系统架构设计师 下午试卷 II
ICML 2022 | 基于随机注意力机制的可解释可泛化图学习
网络安全——XSS之被我们忽视的Cookie
SQL学习(基础)
1W word detailed thread local storage ThreadLocal
作业8.9 构建TCP协议的服务器
【目标检测】小脚本:提取训练集图片与标签并更新索引
EVE模拟器的使用-带图超详细(学网络用)「建议收藏」
C# WPF image is displayed without problems, but the solution does not display the image at runtime
Second half of 2011 System Architect Afternoon Paper II
A method that can make large data clustering 2000 times faster
1W字详解线程本地存储 ThreadLocal
雨水中存在的PFAS化学物质对饮用水安全构成了威胁
the height of the landscape
The recursive recursive Fighting_ silver study ah but level 4
数据产品经理那点事儿 一