From the fine manual:
8.3. Character Types
[...]
The notations varchar(n)
and char(n)
are aliases for character varying(n)
and character(n)
, respectively.
So the real type name is character varying
but you can use varchar
if you want. Similarly for integer types:
8.1.1. Integer Types
[...]
SQL only specifies the integer types integer
(or int
), smallint
, and bigint
. The type names int2
, int4
, and int8
are extensions, which are also used by some other SQL database systems.
So you can say int4
if you want but internally that's integer
.
You can even check what the database really thinks using psql
:
=> create table users (name varchar(255), age int4);
CREATE TABLE
=> \d users
Table "public.users"
Column | Type | Modifiers
--------+------------------------+-----------
name | character varying(255) |
age | integer |
No varchar
or int4
in sight, just character varying
and integer
. You can use the aliases when creating tables but the database will always talk to you using the standard types.
You'll find similar shenanigans going on if you use decimal(m,n)
(an alias for numeric(m,n)
), timestamp
(really timestamp without time zone
), etc.