如何将 MySQL 列从 long 重命名为其他内容 [英] How to rename a MySQL column from long to something else

查看:39
本文介绍了如何将 MySQL 列从 long 重命名为其他内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列名为long"的数据库表.它是MySQL的关键字,不确定是关键字冲突还是什么,我无法使用此关键字列名称运行一些简单的SQL脚本.我尝试运行 SQL 来更改列名,使用:alter table mytable change column long lng double 但它不起作用.

I have a database table with a column name as 'long'. It is a keyword of MySQL and not sure whether it is a keyword conflict or something, I cannot run some of the simple SQL script using this keyword-column name. I try to run the SQL to alter the column name, using: alter table mytable change column long lng double but it doesn't work.

问题是,阻止上述简单的alter SQL工作的原因是什么?(对于手头的任何其他列,上述 SQL 有效)如果是关键字冲突的原因,我该如何使其工作?我可以在 MySQL 中使用任何关键字转义符号吗?

The question is, what's the reason from prevent the above simple alter SQL from working? (For any other columns on hand, the above SQL works) and how can I make it work if it is a reason of keyword conflict? Is there any keyword escape symbol that I can use in MySQL?

非常感谢.

推荐答案

尝试过:

ALTER TABLE mytable CHANGE COLUMN `long` lng DOUBLE

(反引号是,AFAIK,特定于 MySQL.)

(The backtick is, AFAIK, MySQL specific.)

标识符可以带引号或不带引号.如果标识符包含特殊字符或保留字,则在引用它时必须引用它....标识符引号字符是反引号 ("`") (source)

An identifier may be quoted or unquoted. If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it. ... The identifier quote character is the backtick ("`") (source)

这篇关于如何将 MySQL 列从 long 重命名为其他内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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