首页 > 解决方案 > 找不到无法重命名表的原因

问题描述

该问题的原因可能是什么:

Applying django_orm.0002_rename_tables_...Traceback (most recent call last):
   File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
     return self.cursor.execute(sql, params)
 psycopg2.errors.SyntaxError: syntax error at or near "."
"fergo"."tb_kel" RENAME TO "fergo"."tb_kelo"
"fergo"."tb_sa" RENAME TO "fergo"."tb_sartop"

肯定没有错字或语法错误之类的。所有要重命名的表都会出现此错误。有什么想法吗?

标签: django

解决方案


问题是这样的:


alter table public.shoes rename to public.shoe_test;
ERROR:  syntax error at or near "."
LINE 1: alter table public.shoes rename to public.shoe_test;

alter table public.shoes rename to shoe_test;
ALTER TABLE

您不能架构限定新名称。

如果您想要更改架构,那么您需要使用:

ALTER TABLE [ IF EXISTS ] name
    SET SCHEMA new_schema

推荐阅读