difference b/w text and varchar datatypes

Started by Harpreet Dhaliwalover 19 years ago5 messagesgeneral
Jump to latest
#1Harpreet Dhaliwal
harpreet.dhaliwal01@gmail.com

Hi,
Just wanted to know how would it make a difference if i use text datatype
instead of varchar.

Thanks,
~Harpreet

#2Bruce Momjian
bruce@momjian.us
In reply to: Harpreet Dhaliwal (#1)
Re: difference b/w text and varchar datatypes

Harpreet Dhaliwal wrote:

Hi,
Just wanted to know how would it make a difference if i use text datatype
instead of varchar.

See FAQ item.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#3Harpreet Dhaliwal
harpreet.dhaliwal01@gmail.com
In reply to: Bruce Momjian (#2)
Re: difference b/w text and varchar datatypes

can you please provide me the link for the same.
thanks

Show quoted text

On 10/16/06, Bruce Momjian <bruce@momjian.us> wrote:

Harpreet Dhaliwal wrote:

Hi,
Just wanted to know how would it make a difference if i use text

datatype

instead of varchar.

See FAQ item.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#4Richard Broersma Jr
rabroersma@yahoo.com
In reply to: Harpreet Dhaliwal (#1)
Re: difference b/w text and varchar datatypes

Just wanted to know how would it make a difference if i use text datatype
instead of varchar.

Taken from: http://www.postgresql.org/docs/8.1/interactive/datatype-character.html
"
If character varying is used without length specifier, the type accepts strings of any size. The
latter is a PostgreSQL extension.

In addition, PostgreSQL provides the text type, which stores strings of any length. Although the
type text is not in the SQL standard, several other SQL database management systems have it as
well.

...

Tip: There are no performance differences between these three types, apart from the increased
storage size when using the blank-padded type. While character(n) has performance advantages in
some other database systems, it has no such advantages in PostgreSQL. In most situations text or
character varying should be used instead.
"

Regards,

Richard Broersma Jr.

#5Richard Broersma Jr
rabroersma@yahoo.com
In reply to: Harpreet Dhaliwal (#3)
Re: difference b/w text and varchar datatypes

can you please provide me the link for the same.
thanks

The faq is under the documentation link of the PostgreSQL homepage.

http://www.postgresql.org/docs/faq/