PDA

View Full Version : PostGreSQL8: Relation "<table>" Does Not Exist



TheShaner
May 9th, 2007, 04:26 PM
Why oh why do I get this? I've attempted putting quotes around my table name in my SQL query, but it still does not remedy this. I shouldn't need the quotes anyway, seeing that the table name is in all lowercase. When working in phpPgAdmin, I can insert rows just fine using the INSERT feature, but cannot when using the SQL feature. I have a feeling it has to do something with my sequence number that is suppose to be automatically generated, although it's copied and used exactly like my other sequences.

The default value of my order_id field in my propack_order table is set to nextval('"propack_order_order_id_seq"'::text). That sequence is just an integer, starts at 1 and increments by 1.

SQL looks like:

INSERT INTO propack_order (member) VALUES ('Shane')
Which should result in an automatic assignment of the next integer in the sequence for order_id and a member name of Shane and the rest of the columns null (and yes, they're allowed to be null).

-Shane

GJay
May 10th, 2007, 10:24 PM
what you've posted should work, provided propack_order is actually the name of the table. The error seems to imply that it might not be.
typing \dt in psql definitely has it as you've spelt it? and the schema column shows 'public'? post the output of 'd propack_order'
How did you create the table? In particular the id column- did you use the 'serial' type, or create the sequence manually and set it as the default? When I create a sequence via either method, it shows the cast to 'regclass' rather than 'text' in your post (the ::'text' after the sequence name).

TheShaner
May 11th, 2007, 02:23 PM
GJay, thanks so much for trying to help. I didn't think there was anyone in these forums that would, haha.

However, the problem has been solved and had nothing to do with me, which is good, haha. Apparently, the guy who runs the servers has been having problems with them. phpPgAdmin was showing that I had created the table and sequence (I had even recreated them several times) and I was even able to alter them. However, the DB never seemed to recognize the sequence and table. The next day, phpPgAdmin wouldn't allow me to login and that continued for the next couple days. It went back up today and both the sequence and table didn't exist. I created them, yet again, and it works just fine now. Interesting.

Thanks for trying GJay!

-Shane