Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PSQL Field Length Query

Status
Not open for further replies.

pennstump

Technical User
Nov 6, 2003
12
US
Is there a way to query the db for the maximum length of a field for error-checking/truncation before writing?

Thanks.
 
here you are a query

SELECT pg_class.relname, pg_attribute.attname, pg_type.typname, pg_attribute.atttypmod-4
FROM pg_class, pg_attribute, pg_type
WHERE pg_attribute.attrelid = pg_class.oid
AND pg_attribute.atttypid = pg_type.oid
AND pg_class.relname = 'TABLE_NAME'
AND pg_attribute.attname = 'FIELD_NAME'

for more information on the pg_catalog you can see here
it is for varsion 7.3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top