PostgreSQL Equivalents of Data Types in SQL Server
Hello everyone,
In this article, I will try to show the PostgreSQL equivalents of data types in SQL Server.
SQL Server and PostgreSQL have similar data types. Most are equal but some are not. When migrating from SQL Server to PostgreSQL, it is important to keep the correct type mapping in mind and use the table below.
SQL Server | PostgreSQL |
BIGINT | BIGINT |
BINARY(n) | BYTEA |
BIT | BOOLEAN |
CHAR(n), CHARACTER(n) | CHAR(n), CHARACTER(n) |
DATE | DATE |
DATETIME | TIMESTAMP(3) |
DATETIME2(p) | TIMESTAMP(p) |
DATETIMEOFFSET(p) | TIMESTAMP(p) WITH TIME ZONE |
DECIMAL(p,s), DEC(p,s) | DECIMAL(p,s), DEC(p,s) |
DOUBLE PRECISION | DOUBLE PRECISION |
FLOAT(p) | FLOAT(p) |
IMAGE | BYTEA |
INT, INTEGER | INT, INTEGER |
MONEY | MONEY |
NCHAR(n) | CHAR(n) |
NTEXT | TEXT |
NUMERIC(p,s) | NUMERIC(p,s) |
NVARCHAR(n) | VARCHAR(n) |
NVARCHAR(max) | TEXT |
REAL | REAL |
ROWVERSION | BYTEA |
SMALLDATETIME | TIMESTAMP(0) |
SMALLINT | SMALLINT |
SMALLMONEY | MONEY |
TEXT | TEXT |
TIME(p) | TIME(p) |
TIMESTAMP | BYTEA |
TINYINT | SMALLINT |
UNIQUEIDENTIFIER | UUID or CHAR(16) |
VARBINARY(n), VARBINARY(max) | BYTEA |
VARCHAR(n) | VARCHAR(n) |
VARCHAR(max) | TEXT |
XML | XML |
Good luck to everyone in business and life.