Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What advantage to use varchar instead of text data type? [duplicate]

I am creating a table on PostgreSQL I know that the file is a char data type but despite I know that it will store maximum 100 chars I would like to know the next:

What are the advantages of a character or character varying instead of text?

What I think I know

If I am not wrong character is fixed length reserved in memory, and varchar is variable, the same as Text data type. This last is able to store at 1 GB of data but with a minimum of 0 kb, the same minimum as the varchar and char.

Hypothetical case

Then, guess that I am very lazy and despite I know that maximum I will store 100 chars I use text because it is able to store this 100chars and more if in the future is needed. What characteristics I am losing here to not use the appropriate data type?

like image 996
mrc Avatar asked Mar 08 '17 07:03

mrc


1 Answers

There is no significant difference between VARCHAR and TEXT:

PostgreSQL: Difference between text and varchar (character varying)

like image 124
Matthias Danetzky Avatar answered Oct 04 '22 01:10

Matthias Danetzky