Redshift Observatory

System Table Tracker

System view information_schema.key_column_usage version 1.0.56952 / 2023-09-29

schema name column data type
information_schema key_column_usage column_name sql_identifier
information_schema key_column_usage constraint_catalog sql_identifier
information_schema key_column_usage constraint_name sql_identifier
information_schema key_column_usage constraint_schema sql_identifier
information_schema key_column_usage ordinal_position cardinal_number
information_schema key_column_usage table_catalog sql_identifier
information_schema key_column_usage table_name sql_identifier
information_schema key_column_usage table_schema sql_identifier

View Text

SELECT CAST(current_database() AS information_schema.sql_identifier) AS constraint_catalog,
       CAST(nc.nspname AS information_schema.sql_identifier) AS constraint_schema,
       CAST(c.conname AS information_schema.sql_identifier) AS constraint_name,
       CAST(current_database() AS information_schema.sql_identifier) AS table_catalog,
       CAST(nr.nspname AS information_schema.sql_identifier) AS table_schema,
       CAST(r.relname AS information_schema.sql_identifier) AS table_name,
       CAST(a.attname AS information_schema.sql_identifier) AS column_name,
       CAST(pos.n AS information_schema.cardinal_number) AS ordinal_position
FROM pg_namespace AS nr,
     pg_class AS r,
     pg_attribute AS a,
     pg_namespace AS nc,
     pg_constraint AS c,
     pg_user AS u,
     information_schema._pg_keypositions() AS pos (n)
WHERE nr.oid = r.relnamespace
  AND r.oid = a.attrelid
  AND r.oid = c.conrelid
  AND nc.oid = c.connamespace
  AND (c.conkey)[pos.n] = a.attnum
  AND NOT a.attisdropped
  AND (c.contype = CAST('p' AS "char")
    OR c.contype = CAST('u' AS "char")
    OR c.contype = CAST('f' AS "char"))
  AND r.relkind = CAST('r' AS "char")
  AND r.relowner = u.usesysid
  AND u.usename = CAST("current_user"() AS name)


Home 3D Друк Blog Bring-Up Times Consultancy Cross-Region Benchmarks Email Forums IRC Mailing Lists Reddit Redshift Price Tracker Redshift Version Tracker Redshift Workbench System Table Tracker The Known Universe Twitter White Papers