Redshift Observatory

System Table Tracker

System view information_schema.table_constraints version 1.0.62614 / 2024-02-02

schema name column data type
information_schema table_constraints constraint_catalog sql_identifier
information_schema table_constraints constraint_name sql_identifier
information_schema table_constraints constraint_schema sql_identifier
information_schema table_constraints constraint_type character_data
information_schema table_constraints initially_deferred character_data
information_schema table_constraints is_deferrable character_data
information_schema table_constraints table_catalog sql_identifier
information_schema table_constraints table_name sql_identifier
information_schema table_constraints 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(CASE
              WHEN c.contype = CAST('c' AS "char")
                THEN CAST('CHECK' AS text)
              WHEN c.contype = CAST('f' AS "char")
                THEN CAST('FOREIGN KEY' AS text)
              WHEN c.contype = CAST('p' AS "char")
                THEN CAST('PRIMARY KEY' AS text)
              WHEN c.contype = CAST('u' AS "char")
                THEN CAST('UNIQUE' AS text)
              ELSE CAST(NULL AS text)
            END AS information_schema.character_data) AS constraint_type,
       CAST(CASE
              WHEN c.condeferrable
                THEN CAST('YES' AS text)
              ELSE CAST('NO' AS text)
            END AS information_schema.character_data) AS is_deferrable,
       CAST(CASE
              WHEN c.condeferred
                THEN CAST('YES' AS text)
              ELSE CAST('NO' AS text)
            END AS information_schema.character_data) AS initially_deferred
FROM pg_namespace AS nc, pg_namespace AS nr, pg_constraint AS c, pg_class AS r, pg_user AS u
WHERE nc.oid = c.connamespace
  AND nr.oid = r.relnamespace
  AND c.conrelid = r.oid
  AND r.relowner = u.usesysid
  AND r.relkind = CAST('r' AS "char")
  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