Difference between Text and Varchar

There is no behavior difference between varchar and text. The difference between varchar(n) and text is that the length of the value for varchar(n) is limited to n. The internal storage for both (all three?) types is the same, although each has its own unique type identifier.
Both varchar[(n)] and text exist because in the original postgres, text came first. Then varchar[(n)] was added for SQL spec compliance. There are no plans to eliminate one type in favor of the other or consolidate their unique type identifiers. Since they share the same internal representation, however, that also is unlikely to change.
The reasons to use varchar[(n)] are: * ODBC handling of varchar is better than text * Enforcing limits on data lengths. * Portability between Databases. The reasons to use text are: * Fewer casts, implicit or explicit (faster) * It is the native character type * No need to enforce length limits

[Source : GeneralBits]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s