Reputation: 14026
I'm using postgres database and it has table with name say 'System Tenant'. Now I want to make query on it, I do -
select * from "System Tenant";
but it results into error -
ERROR: relation "System Tenant" does not exist
LINE 1: select * from "System Tenant"
^
Could you please suggest how I can resolve it?
Upvotes: 3
Views: 4976
Reputation: 51406
lets say:
so=# create schema t;
CREATE SCHEMA
so=# create table t."Bad Name"();
CREATE TABLE
so=# create table "b@d Name"();
CREATE TABLE
now find all:
so=# select oid::regclass from pg_class where relname ilike '% name%';
oid
--------------
t."Bad Name"
"b@d Name"
(2 rows)
and use exactly as it is listed:
so=# select * from t."Bad Name";
--
(0 rows)
or
so=# select * from "b@d Name";
--
(0 rows)
Upvotes: 3