View postgres_showschema.sql
-- This function replicates the functionality of \d table_name
-- It's useful if you work in a sql tool such as intelliJ, where \d does not work.
--- usage: select * from check_schema('table_name');
drop function check_schema(text);
CREATE FUNCTION check_schema(text)
RETURNS TABLE (f1 text, attname name, format_type text, substr text, attnotnull boolean, attnum smallint) AS $$
BEGIN
RETURN QUERY
SELECT $1 as f1, a.attname, pg_catalog.format_type(a.atttypid, a.atttypmod),