Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 554
  • Last Modified:

how big is Text in Postgres?

I set up a table schema using hiberante.

the config is

            <property name="bio"  not-null="true" type="text" length="2000" >
                  <column name="BIO" default="''" />

when I look at the table schema using a sql client, the field type is indeed "Text", but no indication of size.

How do find out what size was really allocated?
  • 2
  • 2
3 Solutions
Reza RadCommented:
TEXT is for strings of "unlimited" length (though all fields in PostgreSQL are subject to a maximum value length of one gigabyte).


bhomassAuthor Commented:
is there an alternative to set the max length at 2000, let's say?
If you want a character field to be limited in size in PostgreSQL, use "character varying(<size>)" or "varchar(<size>)", where you set <size> to the desired length limit.

Using 'psql', this command would change the column definition to use the 'varchar(2000)' type.

  ALTER TABLE your_table ALTER COLUMN bio TYPE varchar(2000);

This will only work if all records have 2000 characters or less in the 'bio' field.

With Hibernate, it would appear that you'd want the type to be "string" instead of "text".
bhomassAuthor Commented:
thanks for the advice. I am going to reward the points, but could someone give me some guidance whether I suffer performance and efficiency setback by staying with Text type?

it seems since Text has no max, it must be allocating space as the data grows. in that sense, it is not very different from varchar.

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now