[英]Rename a table in Amazon Redshift
I've been trying to rename a table from "fund performance" to fund_performance in SQLWorkbench for a Redshift database.我一直在尝试将 Redshift 数据库的 SQLWorkbench 中的表从“基金绩效”重命名为fund_performance。 Commands I have tried are:
我尝试过的命令是:
alter table schemaname."fund performance"
rename to fund_performance;
I received a message that the command executed successfully, and yet the table name did not change.我收到一条消息,命令执行成功,但表名没有改变。 I then tried copying the table to rename it that way.
然后我尝试复制表格以重命名它。 I used
我用了
#CREATE TABLE fund_performance LIKE "schema_name.fund performance";
CREATE TABLE fund_performance AS SELECT * FROM schema_name."fund performance";
In both these cases I also received a message that the statements executed successfully, but nothing changed.在这两种情况下,我还收到一条消息,说明语句执行成功,但没有任何改变。 Does anyone have any ideas?
有没有人有任何想法?
Use following it may work out for you使用以下它可能对你有用
SELECT * into schema_name.fund_performance FROM schema_name.[fund performance]
It will copy the data by creating new table as fund_performance but it won't create any constraints and Identity's它将通过创建新表作为fund_performance来复制数据,但不会创建任何约束和身份
To Rename specific table without disturbing existing constraints在不干扰现有约束的情况下重命名特定表
EXEC sp_rename 'schema_name.[fund performance]', 'schema_name.fund_performance';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.