How can we use MongoDb with postgresql?

Is char(1) really use one byte space in postgresql?

  • Hello guys:  I am a newbie to PostgreSQL database. I meet a problem when using PostgreSQL database. In the document http://www.postgresql.org/docs/9.1/interactive/datatype-character.html It's said that "char" use single-byte. Here is my test: CREATE TABLE test (text char(1)); and then I use: insert into test (test) values ('â–¶'); (â–¶ is a special char who's utf8 decode is 9654 (base 10).) It carried out perfect. And I use: SELECT * from test;  test ------  â–¶ (1 row) How can single-byte store â–¶ ? (PostgreSQL 9.1.9 on x86-64 Debian 7 OS)

  • Answer:

    From the link you posted (emphasis mine) 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. ... The notations varchar(n) and char(n) are aliases for character varying(n) and character(n), respectively. character without length specifier is equivalent to character(1).

Bo Shi at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.