Related:
For query writing purposes I want to have nice short actual column names.
However, from my actual data source, I have an extremely long "canonical" name for each field. (This was the column name in the source.)
When showing my query results, I would like to show these long column names.
How can I do this?
I considered a couple ways of approaching this:
- I could COMMENT ON each column, which would at least store the long names directly in the table definition, but this wouldn't show the comments with each query result. (Unless there's some way to do that...?)
- I could make a big column alias block of code that I could copy and paste for each query, but that would only work if I'm returning ALL the columns, which isn't likely in most cases.
- I could try some fancy magic with the information schema (or system tables) and use PL/pgSQL to run every query so it gives the desired column names. (I wouldn't know how to approach this, actually, though I have a decent grasp of PL/pgSQL.)
- There must be some better way I haven't thought of...can you help me here?
COMMENT
and put the extended names in the rendering engine. – Evan Carroll Nov 30 '17 at 6:52SELECT col_description('foo'::regclass, 1);
for the first column of the tablefoo
. And the downside is internationalization is hard in this fashion unless you store keys into a il8n dictionary, in which case you may as well use a short column name. This is only an issue if you're internationalizing. – Evan Carroll Nov 30 '17 at 7:27