I have a table called schemas, it has:
- unique_id (varchar) - contains table names
- data (text)
each unique_id on the schemas rows has a table with similar columns, for example: users (id, data), holidays (id, data), etc..
Is it possible to query from those tables without typing one by one?
CREATE TABLE schemas (
unique_id VARCHAR(32) PRIMARY KEY, // table names stored here
data TEXT
);
INSERT INTO schemas VALUES('users','foo'),('holidays','bar');
-- not just users and holidays, there are many more..
CREATE TABLE users (
id BIGSERIAL,
data TEXT
);
INSERT INTO users(data) VALUES('user1'),('user2');
CREATE TABLE holidays (
id BIGSERIAL,
data TEXT
);
INSERT INTO holidays(data) VALUES('hol1'),('hol2');
-- and so on, if a record added to the schemas,
-- a new table created with unique_id name
Is it possible to do a single query without PL/* that could give a result something like this:
schema_unique_id | schema_data | table_data
users | foo | user1
users | foo | user2
holidays | bar | hol1
holidays | bar | hol2