What is the difference between CHARACTER VARYING and VARCHAR in PostgreSQL?
-
20-09-2019 - |
Question
John uses CHARACTER VARYING
in the places where I use VARCHAR
.
I am a beginner, while he is an expert.
This suggests me that there is something which I do not know.
What is the difference between CHARACTER VARYING and VARCHAR in PostgreSQL?
Solution
Varying is an alias for varchar, so no difference, see documentation :)
The notations varchar(n) and char(n) are aliases for character varying(n) and character(n), respectively. character without length specifier is equivalent to character(1). If character varying is used without length specifier, the type accepts strings of any size. The latter is a PostgreSQL extension.
OTHER TIPS
The PostgreSQL documentation on Character Types is a good reference for this. They are two different names for the same type.
The only difference is that CHARACTER VARYING is more human friendly than VARCHAR
Both are the same thing but many of the databases are not providing the varying char mainly postgreSQL is providing. So for the multi database like Oracle Postgre and DB2 it is good to use the Varchar