patternMinor
Redshift: Table columns can be found in information_schema.columns but not in pg_catalog.pg_table_def
Viewed 0 times
canpg_catalogcolumnsredshiftbutinformation_schemafoundpg_table_defnottable
Problem
I create a table in Redshift. When I tried to search for the table definition, I get back results from
However, when I run a query against
Could anyone help me understand why this is happening? The table is created and owned by the account I'm using.
information_schema.columns by running the following query: select * from information_schema.columns
where table_name = 'table' and table_schema='schema'However, when I run a query against
pg_catalog.pg_table_def, I don't get back any result. select * from pg_catalog.pg_table_def
where tablename = 'table' and schemaname = 'schema'Could anyone help me understand why this is happening? The table is created and owned by the account I'm using.
Solution
Check
As stated on the original AWS redshift documentation.
PG_TABLE_DEF only returns information about tables that are visible to the user.
to get what you want you should run
Hope that helps.
show search_path; to make sure you are on the current path where the table was created.As stated on the original AWS redshift documentation.
PG_TABLE_DEF only returns information about tables that are visible to the user.
to get what you want you should run
set search_path to '$user', '';
select * from pg_catalog.pg_table_def where tablename = '';Hope that helps.
Context
StackExchange Database Administrators Q#199091, answer score: 3
Revisions (0)
No revisions yet.