首页 > 解决方案 > 为什么我在 Redshift for select insert into 中收到此错误?

问题描述

我几乎一字不差地从另一个用户的代码中复制了另一个数据库系统(SQL Server 或 Oracle),我需要在 Redshift 中使用。

我创建了一个表:

create table #Tablelist(
    tableid int identity(1,1)
    ,table_name varchar(50) not null
    ,primary key (table_name)
);

但是当我运行这个时:

insert into #Tablelist(table_name)
select distinct tablename
from pg_table_def
where tablename like '%some_pattern%';

红移 说:

 Invalid operation: Specified types or functions (one per INFO message) not supported on Redshift tables.;

这部分工作正常:

select distinct tablename
from pg_table_def
where tablename like '%some_pattern%';

标签: sqlselectinsertamazon-redshift

解决方案


和约束在Redshiftidentity中不起作用。尝试在没有约束的情况下重新创建表,然后尝试插入数据。not nullprimary key


推荐阅读