1

我正在尝试删除存储在 PostgreSQL 8.3.8 32 位中的一张表。

奇怪的是我的桌子没有名字,它是空的。我在哪里做:

SELECT * FORM pg_catalog.pg_tables;

它说我的表名名称为空。当我尝试删除我的表时:

DROP TABLE sde. ;

其中 sde 是我的模式名,出现错误,告诉我存在语法错误。

ERROR: syntax error at or near ";"
LINE 1:drop table sde. ;

有什么办法可以删除那个表吗?

我也试过了

DROP TABLE sde.'';

但仍然出现错误。

我的表有 OID。是否可以通过 OID 删除它?

对我来说最好的解决方案是重命名该表,以便我可以从该表中保存我的数据。

4

1 回答 1

1

You cannot create table with empty name:

tgr=# create table "" ();
ERROR:  zero-length delimited identifier at or near """"
LINE 1: create table "" ();

However you can create a table with a lot of spaces, including newlines:

create table "               

                   " ();

To work with such table:

  1. Find it in information_schema.tables
  2. Copy/paste table name in some command in double quotes ("")

When the previous fails, you can try to update pg_class directly. If you have table OID, try this:

update pg_class set relname = 'test'::name where oid = <<YourOID>>;
于 2014-02-18T10:21:38.040 回答