1

I want to know tables' columns' sizes, to limit inputs' length in the form (I'm also checking it in the backend).

How can I know this?

2

1 Answer 1

3

Try this query, it returns all the column name, data type, maximum lengths for a given table 'table_name'.

SELECT column_name, data_type, character_maximum_length
FROM information_schema.columns 
WHERE table_schema = 'public'
AND table_name = 'table_name';

You could modify it to return one column replacing 'column_name' with yours like so:

SELECT column_name, data_type, character_maximum_length
FROM information_schema.columns 
WHERE table_schema = 'public'
AND table_name = 'table_name'
AND column_name = 'column_name';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.