1

I'm trying to remove one of my tables stored in PostgreSQL 8.3.8 32bit.

Strange is that my table doesn't have a name, it's empty. Where I do:

SELECT * FORM pg_catalog.pg_tables;

it says that me tablename name is null. When I try to delete my table:

DROP TABLE sde. ;

where sde is my schemaname, error appears, telling me that there is a syntax error.

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

Is there any way to delete that table?

I also tried that

DROP TABLE sde.'';

But still error appears.

My table has OID. Is it possible to delete it by OID?

The best solution for me would be renaming that table, that I can save my data from that table.

3
  • Object names need double quotes, not single qutoes. Try: drop table sde.""; Commented Feb 18, 2014 at 9:47
  • If I insert double quotes error appears: ERROR: zero-length delimited identifier at or near """" LINE 1: DROP TABLE sde.""; Commented Feb 18, 2014 at 9:49
  • 2
    Maybe your tablename consists only of whitespace? (so it isn't actually empty, but e.g. one or several spaces) Commented Feb 18, 2014 at 9:53

1 Answer 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>>;
Sign up to request clarification or add additional context in comments.

5 Comments

I found it in information_schema.tables, its name looks like this ''. I've copied it and added double quotes: DROP TABLE sde."''";. But error appears telling me that table "''" does not exist.
I see. In 9.1.9 this is ok: create table sda."''"(); drop table sda."''"; Maybe this is some bug in older PostgreSQL version.
Do you see this table in pgAdmin? If yes, then you can rename '' table from there. Right-click on table name and then click on Properties. This also works for me.
Yes, I see it, but when I try to delete it, message windows appears: ERROR: syntax error at end of input. LINE 1: drop table sde.
What about updating pg_class directly? I am not sure if this can have some side-effects, but it works for me. If you have OID then: update pg_class set relname = 'test'::name where oid = <<YourOID>>;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.