By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,218 Members | 1,498 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,218 IT Pros & Developers. It's quick & easy.

nvarchar in postgresql

P: 1
I am converting mssql to postgresql , can i know how to use nvarchar in postgresql
Feb 6 '19 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,035
"SQL defines two primary character types: character varying(n) and character(n), where n is a positive integer. Both of these types can store strings up to n characters (not bytes) in length. An attempt to store a longer string into a column of these types will result in an error, unless the excess characters are all spaces, in which case the string will be truncated to the maximum length. (This somewhat bizarre exception is required by the SQL standard.) If the string to be stored is shorter than the declared length, values of type character will be space-padded; values of type character varying will simply store the shorter string."
source: https://www.postgresql.org/docs/9.1/...character.html )

Simply use varchar()
Feb 6 '19 #2

Rabbit
Expert Mod 10K+
P: 12,366
I believe they are referring to the difference between nvarchar and varchar, which in other databases, signify the encoding used to store the string. One stores Unicode characters, the other stores ASCII only.

I have not used postgresql but from the documentation, it doesn't sound like they offer both varchar and nvarchar. Rather it is defined by a setting at the database cluster level.

See their documentation for more detail on the character setting here: https://www.postgresql.org/docs/9.0/multibyte.html
Feb 6 '19 #3

Post your reply

Sign in to post your reply or Sign up for a free account.