PostgreSQL - SPLessons

PostgreSQL Datatypes

Chapter 4

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

PostgreSQL Datatypes

PostgreSQL Datatypes

shape Description

A PostgreSQL Datatypes is a programming language, which contain set of values and data. A PostgreSQL Datatypes defines an appropriate kind of data and data type also defines the attainable values for that type, the operations that should be possible on that sort and then stored the data.

PostgreSQL Datatypes are classified into the following types. They are as follows:

Numeric Datatypes

shape Description

These numeric datatypes consists of integers and floating point numbers.

Types Explanation Size
Integer For integers there will be common decision. Stores 4 bytes.
Decimal Based on client precision. Stores based on variable size.
Numeric Based on client precision. Stores based on variable size.
Smallint The range of integers is very small. Stores 2 bytes in size.
Bigint The range of integer is very large. Stores 8 bytes in size.
Double precision Depands on the precision variable. Store 8 bytes in size.
Serial Inters will get auto increment. Stores 4 bytes in size.
Real Depands on the precision of variables. Stores 4 bytes in size.

Binary Datatypes

shape Description

These binary datatype contain bytea data that stores only the strings that are binary.

Type Explanation Size
Bytea Contains the binary string variable length. Store the string that is real and contains the bytes length of 1 or 4.

Character Datatypes

shape Description

In character datatype variable, it display the character values that are used for general usage.

Type Explanation
Text Variable length is unlimited.
Character varying(n),varchar(n) There is a limit in the length of the variable.
Character(n),char(n) Here the length of the variable is fixed.

Monetary Datatypes

shape Description

The cash sort stores the amount in currency with a settled fragmentary exactness. Estimations of the int, numeric, and bigint information sorts can be thrown to cash.

Type Explanation Size
Money Amount in currency. Storges in 8 bytes.

Date/Time Datatypes

shape Description

Here in the data and time datatype, PostgreSQL will supports all the features of SQL datatype.

Type Explanation Size
Timestamp[(p)][with time zone] Exists time and data along the time zone. Stores 8 bytes in size.
Timestamp[(p)][without time zone] Exits only time and date. Stores 8 bytes in size.
Time[(p)][Doesn’t contain the time zone] day time. Stores 8 bytes in size.
Time[(p)] having time zone. day time along with the time zone. Stores 12 bytes in size.
Date. date. Stores 4 bytes in size.

Boolean Datatypes

shape Description

Here in the boolean datatype the standard boolean types of SQL are used. And there are several types of boolean types exists such as true, false and unknown. Which represent the null values of SQL.

Types Explanation Size
Boolean Determines wheather the set is true or false. Stores one byte in size.


shape Key Points

  • PostgreSQL Datatypes – Is a programming language.
  • Numeric datatype – Consists of integer and floating point numbers.
  • Binary datatype – Contain bytea data.
  • Character datatype – Display character values.
  • Monetary datatype – Evaluates int,numeric and bigint.
  • Date/Time datatype – Supports the features of SQL database.
  • Boolean datatypes – The standard boolean types of SQL are used.