views:

96

answers:

2

I accidentaly created a table in PostgreSQL which contains, in its name, some double quotes. I used SQL Server 2000 DTS to import data from it to my PostgreSQL server, but while importing, it created the table but with double quotes in it.

Actually the table name when I do

SELECT * FROM pg_tables
is :
public","t_freemailer

So, when I try to drop the table using something like :

DROP TABLE "public"."public","t_freemailer"

I get an error : ERROR: table "public" does not exist

And I did not found a way to escape doubles quotes in identifiers name.

Please help

+3  A: 

Use "double" double quotes to escape:

DROP TABLE "public"."public"",""t_freemailer"

Here's a link to the documentation

ChssPly76
A: 

2 x double quote = quote...

DROP TABLE "public"."public"",""t_freemailer"

gbn
Excellent, you've copied my answer which was first and yours was accepted.
ChssPly76
Great, thank you. I tought I already tried this one hehe.
MaxiWheat
lol @ChssPly, the time difference means it's unlikely he copied it! However you've ended up with the rep :)
h4xxr
MaxiWheat in fairness I think you "accepted" the wrong one - i.e. the later of the 2...
h4xxr
@h4xxr - what do you mean by "time difference"? Due to the oh-so-excellent new "feature" by Jeff Atwood (http://meta.stackoverflow.com/questions/17910/please-return-to-the-old-sorting-by-time-method-of-answers-with-the-same-number-o) answers with same number of votes are now ordered randomly rather than by timestamp. Mine was first (you can see that by clicking on "oldest" tab); gbn's (which is exactly the same) was second but was shown first and thus got accepted. It's not about the rep, btw - I'm just really mad about this change (and I'm not alone) but Atwood ain't listening.
ChssPly76
@ChssPly76: no, I just didn't type as fast as you and posted 53 seconds after. I noted it. I also upvoted you when I came back when I saw my rep change. If you think I copied your answer, that's a disturbing mindset you have... do you copy other folks' answers...?
gbn
@gbn - I said "copied" as in "provided an identical one", not "copy / pasted". If I post an answer and see that it's a duplicate of someone else's, I delete mine and up-vote the other one - that's considered good manners on SO as I'm sure you know. I'll ignore the "disturbing mindset" comment - all of this used to not be a huge issue until the change listed in my above comment was made. Note that I did not downvote you or anything; I just think that existing sorting order is fundamentally unfair and I'm frustrated because of that.
ChssPly76
Oh sorry guys, it's my first time on Stackoverflow and I did not even notice which of the answer came first, did not thought it has a significative influence on users scores and what it means. I will take more care next time.
MaxiWheat