0

I have a relation called 'serviceID', exist in PostgreSQL DB. when I run this code

select * from serviceID ;

I got this error:

ERROR:  relation "serviceID" does not exist

why?

Hussein Saad
  • 151
  • 2
  • 15
  • 1
    Databases consist of tables and columns, not "relations". The table name is expected after the `from`. – Gordon Linoff Jul 08 '18 at 13:49
  • What does `SHOW search_path;` show? And in which schema is `serviceid`? If it really is a relation, the name suggests it likely is an attribute, could that be? – sticky bit Jul 08 '18 at 13:53
  • I know (table = relation), so I had serviceID table, and it is after 'form' – Hussein Saad Jul 08 '18 at 13:55
  • it's just a PostgreSQL error @GordonLinoff i agree its a wierd one... Probably the topicstarter has created the serviceID table with double qoutes in the CREATE TABLE statement if thats that case the query could be `select * from "serviceID"` or `select * from database_name.serviceID` – Raymond Nijland Jul 08 '18 at 13:56
  • ohh, it is work for this `select * from "serviceID"` why? – Hussein Saad Jul 08 '18 at 13:58
  • I create this table from sqlalchemy orm models `class serviceID(db.Model):` `id = db.Column(db.Integer, primary_key=True)` `service_id = db.relationship('Service', backref='service', lazy=True)` – Hussein Saad Jul 08 '18 at 14:00
  • 1
    "Why"? i already give a explainment in mine last comment besides i don't know sqlalchemy – Raymond Nijland Jul 08 '18 at 14:02
  • 3
    https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS "*Quoting an identifier also makes it case-sensitive, whereas unquoted names are always folded to lower case. For example, the identifiers `FOO`, `foo`, and `"foo"` are considered the same by PostgreSQL, but `"Foo"` and `"FOO"` are different from these three and each other.*" – melpomene Jul 08 '18 at 14:04
  • Ok anyway, many thanks <3 @RaymondNijland – Hussein Saad Jul 08 '18 at 14:04
  • Good explanation, thanks @melpomene – Hussein Saad Jul 08 '18 at 14:11
  • @melpomene That should be an answer :) – IMSoP Jul 08 '18 at 16:59

0 Answers0