简体   繁体   English

重命名 Amazon Redshift 中的表

[英]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.

相关问题 使用Amazon RedShift旋转表格 - Pivot a table with Amazon RedShift 仅在表存在时如何在Amazon Redshift中删除表 - How to delete a table in Amazon Redshift only if the table exists 如何在 Amazon Redshift 中将数据从表加载和转换到另一个表? - How to load and transform data from Table to another table in Amazon Redshift? 如何在Amazon Redshift中更改表以将两列设置为主键? - How to ALTER TABLE in Amazon Redshift to set two columns as Primary Key? Amazon Redshift:根据表中存在的列列表选择列 - Amazon Redshift: Selecting columns based on a list of columns present in a table 生成具有日期和小时的时间序列并在Amazon Redshift中创建表 - Generate time series with date and hour and create table in Amazon Redshift 如何使用Amazon Redshift中另一个表中的值更新列 - How to update a column using values from another table in Amazon Redshift Amazon Redshift:如何创建包含时间序列的表 - Amazon Redshift: How to create a table containing time series 在 Amazon REdshift 中查看权限 - 重新创建基础表并阻止查看权限 - View Permissions In Amazon REdshift - underlying table is recreated and permissions to view is blocked 在 Amazon Redshift 中使用 Diststyle ALL 的表应该有多小? - How small should a table using Diststyle ALL be in Amazon Redshift?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM