Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Is The PostgreSQL Equivalent To SQL Server NVARCHAR?

Tags:

postgresql

If I have fields of NVARCHAR (or NTEXT) data type in a Microsoft SQL Server database, what would be the equivalent data type in a PostgreSQL database?

like image 997
kevinw Avatar asked Aug 07 '09 14:08

kevinw


People also ask

What is SQL Server NVARCHAR?

SQL Server NVARCHAR data type is used to store variable-length, Unicode string data. The following shows the syntax of NVARCHAR : NVARCHAR(n) In this syntax, n defines the string length that ranges from 1 to 4,000. If you don't specify the string length, its default value is 1.

What is varchar Max in PostgreSQL?

What is PostgreSQL Varchar datatype? In PostgreSQL, the Varchar data type is used to keep the character of infinite length. And it can hold a string with a maximum length of 65,535 bytes.

Is PostgreSQL syntax different from SQL Server?

SQL server is a database management system which is mainly used for e-commerce and providing different data warehousing solutions. PostgreSQL is an advanced version of SQL which provides support to different functions of SQL like foreign keys, subqueries, triggers, and different user-defined types and functions.

What is real datatype in PostgreSQL?

real or float8 is a 4-byte floating-point number. numeric or numeric(p,s) is a real number with p digits with s number after the decimal point. The numeric(p,s) is the exact number.


1 Answers

I'm pretty sure postgres varchar is the same as Oracle/Sybase/MSSQL nvarchar even though it is not explicit in the manual:

http://www.postgresql.org/docs/7.4/static/datatype-character.html

Encoding conversion functions are here:

http://www.postgresql.org/docs/current/static/functions-string.html http://www.postgresql.org/docs/current/static/functions-string.html#CONVERSION-NAMES

Example:

create table nvctest ( utf8fld varchar(12) ); insert into nvctest select convert('PostgreSQL' using ascii_to_utf_8); select * from nvctest; 

Also, there is this response to a similar question from a Postgresql rep:

All of our TEXT datatypes are multibyte-capable, provided you've installed PostgreSQL correctly.
This includes: TEXT (recommended) VARCHAR CHAR

like image 147
karim79 Avatar answered Oct 06 '22 01:10

karim79