简体   繁体   English

如何重命名SQL中的列?

[英]How to rename a column in SQL?

The code that i tried is我试过的代码是

ALTER TABLE "STUDENT" RENAME COLUMN "Roll" TO "Num";

Its syntax is correct but it shows a error.它的语法是正确的,但它显示了一个错误。 Whats the problem?有什么问题?

Error错误

Static analysis:静态分析:

1 errors were found during analysis.分析过程中发现 1 个错误。

Missing comma before start of a new alter operation.在开始新的更改操作之前缺少逗号。 (near "TO" at position 47) SQL query: Copy (在位置 47 的“TO”附近)SQL 查询:复制

ALTER TABLE "STUDENT" RENAME COLUMN "column 1" TO "column 2"

MySQL said: Documentation MySQL 说: 文档

1064 - You have an error in your SQL syntax; 1064 - 你的 SQL 语法有错误; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"STUDENT" RENAME COLUMN "column 1" TO "column 2"' at line 1检查与您的 MariaDB 服务器版本相对应的手册,了解在第 1 行的“STUDENT”RENAME COLUMN“column 1” TO“column 2”'附近使用的正确语法

试试这个方法

 ALTER TABLE "STUDENT" RENAME COLUMN "Roll" TO "Num" datatype(length);

See here for an answer to your question.请参阅此处了解您的问题的答案。

Basically: use backticks instead of quotes.基本上:使用反引号代替引号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM