Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is a varchar unlimited in Postgresql?

Is a varchar unlimited in Postgresql? I read this text online and it was confusing:

"In PostgreSQL, the Varchar data type is used to keep the character of infinite length. And it can hold a string with a maximum length of 65,535 bytes."

Does that mean that in postgres, a varchar can only hold a maximum of 65,535 characters? Or can a varchar hold an unlimited amount of characters?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I need to be able to hold an unlimited amount of characters in the database table. There is a lot of incoming data that could get into the millions of characters per column.

Edit:

So based on replies, is looks like the 65,535 character limit is not true. What is the limit then? Someone said 1GB. Is that true? Is there a way to make a varchar truly unlimited?

>Solution :

The limit for varchar when you specify a length limit (type modifier) is 10485760:

SELECT 'x'::varchar(1000000000);
ERROR:  length for type varchar cannot exceed 10485760

Without the type modifier, the size can be up to 1GB (just like text).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading