Advertisement
linehanp

PostgreSQL_information_schema.tables_query.txt

Mar 6th, 2024
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. --
  2. -- The VIEW which is queries when the command
  3. -- "SELECT * FROM information_schema.views" is issued
  4. --
  5.  
  6. --
  7. -- information_schema. tables
  8. --
  9. -- AS you can see, it contains much of the code
  10. -- that will appear when you issue the command \d
  11. -- (see also \d+) - if you have \set ECHO_HIDDEN on
  12. --
  13. --
  14.  
  15. SELECT
  16. (nc.nspname)::information_schema.sql_identifier AS table_schema,
  17. (c.relname)::information_schema.sql_identifier AS table_name,
  18. (
  19. CASE
  20. WHEN (nc.oid = pg_my_temp_schema()) THEN 'LOCAL TEMPORARY'::text
  21. WHEN (c.relkind = ANY (ARRAY['r'::"char", 'p'::"char"])) THEN 'BASE TABLE'::text
  22. WHEN (c.relkind = 'v'::"char") THEN 'VIEW'::text
  23. WHEN (c.relkind = 'f'::"char") THEN 'FOREIGN'::text
  24. ELSE NULL::text
  25. END)::information_schema.character_data AS table_type,
  26. (NULL::name)::information_schema.sql_identifier AS self_referencing_column_name,
  27. (NULL::character varying)::information_schema.character_data AS reference_generation,
  28. (
  29. CASE
  30. WHEN (t.typname IS NOT NULL) THEN current_database()
  31. ELSE NULL::name
  32. END)::information_schema.sql_identifier AS user_defined_type_catalog,
  33. (nt.nspname)::information_schema.sql_identifier AS user_defined_type_schema,
  34. (t.typname)::information_schema.sql_identifier AS user_defined_type_name,
  35. (
  36. CASE
  37. WHEN ((c.relkind = ANY (ARRAY['r'::"char", 'p'::"char"])) OR ((c.relkind = ANY (ARRAY['v'::"char", 'f'::"char"])) AND ((pg_relation_is_updatable((c.oid)::regclass, false) & 8) = 8))) THEN 'YES'::text
  38. ELSE 'NO'::text
  39. END)::information_schema.yes_or_no AS is_insertable_into,
  40. (
  41. CASE
  42. WHEN (t.typname IS NOT NULL) THEN 'YES'::text
  43. ELSE 'NO'::text
  44. END)::information_schema.yes_or_no AS is_typed,
  45. (NULL::character varying)::information_schema.character_data AS commit_action
  46. FROM ((pg_namespace nc
  47. JOIN pg_class c ON ((nc.oid = c.relnamespace)))
  48. LEFT JOIN (pg_type t
  49. JOIN pg_namespace nt ON ((t.typnamespace = nt.oid))) ON ((c.reloftype = t.oid)))
  50. WHERE ((c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'f'::"char", 'p'::"char"])) AND (NOT pg_is_other_temp_schema(nc.oid)) AND (pg_has_role(c.relowner, 'USAGE'::text) OR has_table_privilege(c.oid, 'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER'::text) OR has_any_column_privilege(c.oid, 'SELECT, INSERT, UPDATE, REFERENCES'::text)));
  51.  
  52.  
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement