NVARCHAR Data Type - SQL Server to PostgreSQL Migration

In SQL Server, NVARCHAR(n) data type stores variable-length Unicode UCS-2 or UTF-16 character strings up to n byte-pairs with the maximum of 4,000 byte-pairs or 2 GB if NVARCHAR(max) is specified.

In PostgreSQL, you can use VARCHAR(n) that can store up to 1 GB (bytes).

SQL Server:

  CREATE TABLE specs
  (
    item   NVARCHAR(30),
    name NVARCHAR(100),
    notes  NVARCHAR(MAX)
  );

PostgreSQL:

  CREATE TABLE specs
  (
    item   VARCHAR(30),
    name VARCHAR(100),
    notes  TEXT
  );

Overview

Conversion summary:

SQL Server PostgreSQL
Syntax NVARCHAR[(n)] VARCHAR[(n)]
Parameter n is the number of byte-pairs n is the number of characters
Range 1 ⇐ n ⇐ 4,000 or 2 GB if MAX is specified 1 ⇐ n ⇐ 10,485,760
Default n is 1 1 GB

For more information, see SQL Server to PostgreSQL Migration.