Michael Hecht
Michael Hecht

Reputation: 2253

Database select all data with table qualifier in PostgreSQL

I need to select from a database some tables with many columns. So I want to select

select t1.*,t2.*,t3.*
from table1 t1 
left outer join table2 t2 on ...
left outer join tabl 3 t3 on ...
...

Some keys are identically named, but - due to the outer command - sometimes null. Unfortunately I cannot directly see whether the key comes from t1, t2 or t3. Is there any chance to add automatically the tablenames or another separating/distinguishing qualifier to all column names, i.e. t1_thekey, t2_thekey, t3_thekey ...?

Upvotes: 1

Views: 160

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270993

Postgres doesn't allow you to rename the columns en masse. However, you could select the columns as records, so you can see where they come from:

select t1, t2, t3

Upvotes: 2

Related Questions