SQL 如何更改 DB2 中的列名

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7385938/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 12:04:56  来源:igfitidea点击:

How to change the column name in DB2

sqldb2

提问by SHAHZZ

I need to rename the column name of one of the table. I have DB2 database and we are connecting with the database and executing sql queries through Eclipse IDE.

我需要重命名其中一个表的列名。我有 DB2 数据库,我们正在连接数据库并通过 Eclipse IDE 执行 sql 查询。

Thanks.

谢谢。

回答by duffymo

Use an ALTER TABLE statement.

使用 ALTER TABLE 语句。

ALTER TABLE G31.TG31PDIX RENAME COLUMN RECORD_KEY TO RECORD_KEYY;

This will only work if you use a version of DB2 that supports this feature. An older version might be out of luck. I'm not sure when they added it, but it was after 2004.

这仅在您使用支持此功能的 DB2 版本时才有效。旧版本可能不走运。我不确定他们何时添加它,但它是在 2004 年之后。