Correct. I suggested this as an enhancement for one reason, GUI allows for really great quick visual identification of information. I do appreciate you sending me this though.
Now that you sent this to me, I might create a function I can passed as a parameter a table name with the results being returned from your below code.
You would think they would have a function already in PostgreSQL to do that.
Thanks,
Lance
From: Melvin Davidson [mailto:melvin6925@yahoo.com] Sent: Wednesday, April 19, 2017 9:18 AM To: Campbell, Lance <lance@illinois.edu>; pgadmin-support@postgresql.org Subject: Re: [pgadmin-support] pgadmin 4 enhancement request
Lance,
I am not a PgAdmin developer, but you can easily accomplish what you want with either of the
following two queries:
-- Returns all columns for a specified table SELECT c.relname as table, a.attname as column, t.typname as type -- t.typlen as length, -- a.attrelid FROM pg_class c JOIN pg_attribute a ON ( a.attrelid = c.oid ) JOIN pg_type t ON (t.oid = a.atttypid ) WHERE relname = '<YOUR_TABLE>' AND attnum > 0 AND NOT attisdropped ORDER BY 2; --a.attnum;
-- OR Use INFORMATION_SCHEMA.COLUMNS SELECT column_name, data_type, character_maximum_length as length, column_default as default FROM INFORMATION_SCHEMA.COLUMNS where table_name = '<YOUR_TABLE>' ORDER BY 1; --ordinal_position;
Melvin Davidson 🎸 Cell 720-320-0155 I reserve the right to fantasize. Whether or not you wish to share my fantasy is entirely up to you. www.youtube.com/unusedhero/videos Folk Alley - All Folk - 24 Hours a day www.folkalley.com
In pgadmin 4 in the left hand navigation you can select the “Columns” label under any table listed in order to get a list of all columns within a table.
A fantast enhancements would be to add to the “File >> Preferences” the ability to do either option #1 or #2 listed below:
1)A question in File >> Preferences to sort the default display of Columns listed in the left hand navigation alphabetically versus the natural table order.
OR
2)A question in the File >> Preferences that says something like “What order would you like the Columns to be listed by default in the left hand navigation:” . Then have three radio button options:
a)Natural order
b)Alphabetical order
c)Grouped by primary key, then foreign keys, then other columns. Within foreign keys and other columns list them alphabetical.
I know you have a lot going on. I am sure this enhancement seems trivial. But when you have a table with a lot of columns this is an amazing feature to have. Before the release of 4-1.4 I was using a different admin tool. I found this feature exceptionally nice and very useful.