CHAR Data Type - SQL Server to PostgreSQL Migration

In SQL Server, CHAR(n) data type stores fixed-length, blank padded character strings up to n bytes with the maximum of 8,000 bytes. In PostgreSQL, you can also use CHAR(n).

SQL Server:

  CREATE TABLE specs
  (
    item   CHAR(30),
    name CHAR(100)
  );

PostgreSQL:

  CREATE TABLE specs
  (
    item   CHAR(30),
    name CHAR(100)
  );

Overview

Conversion summary:

SQL Server PostgreSQL
Syntax CHAR[(n)] CHAR[(n)]
Parameter n is the number of bytes n is the number of characters
Range 1 ⇐ n ⇐ 8,000 1 ⇐ n ⇐ 10,485,760
Default n is 1 n is 1

For more information, see SQL Server to PostgreSQL Migration.