开发者

How to rename a MySQL column from long to something else

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.

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?

Thanks very much.


Tried:

ALTER TABLE mytable CHANGE COLUMN `long` lng DOUBLE

(The backtick is, AFAIK, MySQL specific.)

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)


Try using a "right quote" around "long"

Like this :

`long`


try again query working properly alter table table_name change column long lng double but its neccessary the datatype of long should be integer then try may be your problem solved

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜