SELECT ordinal_position
, column_name
, CASE data_type WHEN 'character varying' THEN data_type || '('||character_maximum_length || ')' ELSE data_type END data_type
, column_default
, is_nullable
, character_maximum_length
, numeric_precision
FROM information_schema.columns
WHERE table_catalog = 'database_name'
AND table_schema = 'schema_name'
AND table_name = 'table_name'
ORDER BY ordinal_position;
Monday, November 5, 2012
PostgreSQL - get table structure
at 7:20 AM
Labels: DBA Tasks, PostgreSQL, PostgreSQL Query, PostgreSQL Tip
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment