Re: Drop table by something other than its name

From: Felix Obermaier <obe(at)IVV-AACHEN(dot)DE>
To: "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Drop table by something other than its name
Date: 2010-03-17 22:17:15
Message-ID: 941E09AD62CA6F41913924A35EA3985E4C643125@ivv-mx.ivv-aachen.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Thanks for your answers,

I've tried the pg_dump-approach with no success:

pg_dump: SQL command failed
pg_dump: Error message from server: ERROR: invalid byte sequence for encoding "UTF8": 0xe3bc72
HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".
pg_dump: The command was: LOCK TABLE public."hp_kreis_dã¼ren" IN ACCESS SHARE MODE
pg_dump: *** aborted because of error

If I enter:
DROP TABLE "hp_kreis_dã¼ren" CASCADE;

I get 'ERROR: invalid byte sequence for encoding "UTF8":0xfc'

I'm sure the name of the table should have been "hp_kreis_düren".

Any Ideas?
Felix Obermaier

-----Ursprüngliche Nachricht-----
Von: Michael Wood [mailto:esiotrot(at)gmail(dot)com]
Gesendet: Mittwoch, 17. März 2010 22:34
An: Tom Lane
Cc: Felix Obermaier; pgsql-novice(at)postgresql(dot)org
Betreff: Re: [NOVICE] Drop table by something other than its name

On 17 March 2010 21:36, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Felix Obermaier <obe(at)IVV-AACHEN(dot)DE> writes:
>> I have a table with a name that contains some akward letter in it so that pgAdmin fails to display it (just empty) and psql omits that character.
>> My problem is that I cannot query that table and I cannot drop it. Is there a way to get rid of this table?
>
> You probably just need to double-quote the table name.

I think he's having trouble finding out what the table name is in the
first place.

Maybe you can use something like this to get the name:

select relname from pg_catalog.pg_class where relkind = 'r' and
relname like 'some%thing';

where 'some%thing' is the table name with % for the part you don't know.

Using "pg_dump -s" to dump the schema might be another way to find the name.

If that doesn't help, you could perhaps get the table name like the
using a perl/python/whatever program and then in the same program
execute a DROP command using the table name you got previously.

I'd make sure you have a good backup first, though, just in case you
accidentally drop the wrong table.

--
Michael Wood <esiotrot(at)gmail(dot)com>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Gurjeet Singh 2010-03-18 05:55:48 Re: PostgreSQL questions
Previous Message Michael Wood 2010-03-17 21:33:34 Re: Drop table by something other than its name