String Data Types

I l @ ve RuBoard

PostgreSQL includes three basic data types for storing string- related data. In compliance with the SQL standard, there are types for fixed-length and variable-length character strings. Additionally, PostgreSQL defines a more generic data type named TEXT that requires no specified upper limit regarding maximum size . However, this data type is PostgreSQL-specific and is not compliant with the SQL-92 standards.

CHAR (or CHARACTER )

Description

Holds a fixed-length string specified with a maximum length.

Inputs
 CHAR(n) 

n ”Integer length of string (if omitted, a 1 is assumed).

Storage Size

(4+n) bytes

Notes

CHAR is a SQL-92-compatible data type. Data that does not fill to the limit specified is blank padded .

TEXT

Description

Holds a variable-length string.

Storage Size

Variable ”depends on the length of string, but no smaller than 4 bytes.

VARCHAR (or CHARACTER VARYING )

Description

Holds a variable-length string with a specified limit.

Inputs
 VARCHAR(n) 

n ”Integer length of string (if omitted, a 1 is assumed).

Storage Size

Variable ”depends on the length of string, but no smaller than 4 bytes.

Notes

VARCHAR and CHARACTER VARYING are both SQL-compatible data types.

I l @ ve RuBoard


PostgreSQL Essential Reference
PostgreSQL Essential Reference
ISBN: 0735711216
EAN: 2147483647
Year: 2001
Pages: 118
Authors: Barry Stinson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net