I run the following command through python3.3 psycopg2 package:

ALTER TABLE my_schema.tbl_old RENAME TO tbl_new

Before the command is run, my python code makes sure tbl_new does not exist. However, I get the following error:

relation "tbl_new" already exists

Table structure:

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

No indices are defined.

Also, when I run the same RENAME command from psql shell, it works well.

Anyone can explain this strange behavior?

Thanks!!!

有帮助吗?

解决方案

Problem found - bug in my python code - it was written 'tbl_Old' (instead of 'tbl_old').

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top