Postgresql 无法在红移中重命名表

Postgresql 无法在红移中重命名表,postgresql,psycopg2,Postgresql,Psycopg2,我通过python3.3 psycopg2包运行以下命令: ALTER TABLE my_schema.tbl_old RENAME TO tbl_new 在运行命令之前,我的python代码确保tbl_new不存在。 但是,我得到以下错误: relation "tbl_new" already exists 表结构: bipilot=# select * from PG_TABLE_DEF where tablename='tbl_old'; schemaname | tablename

我通过python3.3 psycopg2包运行以下命令:

ALTER TABLE my_schema.tbl_old RENAME TO tbl_new
在运行命令之前,我的python代码确保tbl_new不存在。 但是,我得到以下错误:

relation "tbl_new" already exists
表结构:

bipilot=# select * from PG_TABLE_DEF where tablename='tbl_old';
 schemaname | tablename |    column    |     type      | encoding | distkey | sortkey | notnull
------------+-----------+--------------+---------------+----------+---------+---------+---------
 my_schema  | tbl_old   | price        | numeric(10,2) | lzo      | f       |       0 | f
 my_schema  | tbl_old   | price_date   | date          | none     | f       |       1 | f
 my_schema  | tbl_old   | product_id   | smallint      | delta    | f       |       0 | f
没有定义索引

另外,当我从psqlshell运行相同的重命名命令时,它工作得很好

有人能解释这种奇怪的行为吗


谢谢

发现问题-我的python代码中有bug-它是用“tbl_Old”而不是“tbl_Old”编写的。

您能否给出以下结果:select*from PG_TABLE_DEF where tablename='tbl_new'@这是一个空的结果集。