CHARACTER VARYING in the places where I use
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?
VARCHAR is an alias for
CHARACTER VARYING, so no difference, see documentation 🙂
char(n)are aliases for
characterwithout length specifier is equivalent to
character varyingis used without length specifier, the type accepts strings of any size. The latter is a PostgreSQL extension.
Note on capitalization: The PostgreSQL documentation uses the all lower case stylization:
character varying. In contrast the official SQL standard uses the stylization with all caps throughout its 1000 pages:
The short answer: there is no difference.
The long answer:
CHARACTER VARYING is the official type name from the ANSI SQL standard, which all compliant databases are required to support. (SQL compliance Feature ID E021-02.)
VARCHAR is a shorter alias which all modern databases also support. I prefer
VARCHAR because it’s shorter and because the longer name feels pedantic. However, postgres tools like
\d will output
The only difference is that
CHARACTER VARYING is more human friendly than
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