Adding multiple columns AFTER a specific column in MySQL(在 MySQL 中的特定列之后添加多列)
问题描述
我需要向表中添加多列,但将列定位在之后名为lastname的列.
I need to add multiple columns to a table but position the columns after a column called lastname.
我已经试过了:
ALTER TABLE `users` ADD COLUMN
(
`count` smallint(6) NOT NULL,
`log` varchar(12) NOT NULL,
`status` int(10) unsigned NOT NULL
)
AFTER `lastname`;
我收到此错误:
您的 SQL 语法有错误;检查手册对应于您的 MySQL 服务器版本以使用正确的语法靠近 ') AFTER lastname' 在第 7 行
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AFTER
lastname' at line 7
如何在这样的查询中使用 AFTER?
How can I use AFTER in a query like this?
推荐答案
试试这个
ALTER TABLE users
ADD COLUMN `count` SMALLINT(6) NOT NULL AFTER `lastname`,
ADD COLUMN `log` VARCHAR(12) NOT NULL AFTER `count`,
ADD COLUMN `status` INT(10) UNSIGNED NOT NULL AFTER `log`;
检查语法
这篇关于在 MySQL 中的特定列之后添加多列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 MySQL 中的特定列之后添加多列
基础教程推荐
- oracle区分大小写的原因? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 在多列上分布任意行 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
