Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pgSQL Character Limitations

Tags:

postgresql

I am still relatively new to pgSQL after switching away from mySQL completely.

I am trying to find the character limitations, if any, that pgSQL may or may not have. Specifically I am curious if there is a character limit on the following?

  1. Database Name Length (mySQL is 64 characters)
  2. Username Length (mySQL is 16 characters)
  3. Password Length

I've been searching Google, I've read the pgSQL FAQ, and a few random other posts but I haven't found a solid answer to any of these. Perhaps pgSQL does not have these limitations like mySQL does. If anyone could shed some light on this that would be great!

I am currently using pgSQL 9.3.1

like image 207
Diemuzi Avatar asked Oct 21 '13 15:10

Diemuzi


People also ask

What is the limit for TEXT in Postgres?

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

What is CHAR [] in PostgreSQL?

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) . If character varying is used without length specifier, the type accepts strings of any size. The latter is a PostgreSQL extension.

Should I use VARCHAR or TEXT in Postgres?

Different from other database systems, in PostgreSQL, there is no performance difference among three character types. In most cases, you should use TEXT or VARCHAR . And you use the VARCHAR(n) when you want PostgreSQL to check for the length.


1 Answers

The length for any identifier is limited to 63 characters:

http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

By default, NAMEDATALEN is 64 so the maximum identifier length is 63 bytes

As username and database name are identifiers, that limit should apply to them.

I'm not aware of any length limitation on passwords (although I'm sure there is one).

like image 78
a_horse_with_no_name Avatar answered Sep 30 '22 12:09

a_horse_with_no_name