无法创建索引。获取'关系已存在'错误

时间:2015-07-03 14:15:44

标签: python postgresql

当我尝试在表上创建索引时,我收到此错误消息。该表的架构如下所示:

 CREATE TABLE object(
     id int, 
     id_obj int,
     id_parent int        
 )

所以,当我这样做时(在Python代码中):

cursor.execute('CREATE INDEX id_idx ON object(id)')
# or
cursor.execute('CREATE INDEX id_obj_idx ON object(id_obj)')

我收到以下错误消息:

psycopg2.ProgrammingError: relation "id_idx" already exists
# or
psycopg2.ProgrammingError: relation "id_obj_idx" already exists

这有什么问题?

0 个答案:

没有答案