在MySQL中的特定列之后添加多个列 [英] Adding multiple columns AFTER a specific column in MySQL

查看:99
本文介绍了在MySQL中的特定列之后添加多个列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将多个列添加到一个表中,但将列放置在 之后的位置 .

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服务器版本以使用正确的语法 在第7行的lastname'之后')附近

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中的特定列之后添加多个列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆