C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
PostgreSQL Data TypesA data type specifies what kind of data you want to store in the table field. While creating a table, for each column, you have to use a datatype. It identifies a particular type of data, like integer, Boolean, floating points, and so on. In this section, we are going to discuss the various data types used in PostgreSQL. In PostgreSQL, each database table has many columns and has precise data types for each column. It supports an extensive range of data types. Also, users can create their custom data type using the CREATE TYPE SQL command. And these data types have the following advantages:
In PostgreSQL, we have many sets of data types; let us understand them one by one:
Numeric Data TypeNumeric datatype is used to specify the numeric data into the table. It contains the following:
The below table contains all numeric data types that support in PostgreSQL:
Character Data TypeIn PostgreSQL, we have various general purpose character data types, and these data types are used to represent the character type values. The below table contains all Character data types that are supported in PostgreSQL:
Date/Time Data TypeThe PostgreSQL supports the complete set of SQL date and times data types. The date/time datatypes are used to represent the columns using date and time values. Based on the Gregorian calendar, the dates are counted. The below table contains all date/ time data types that are supported in PostgreSQL:
|
Description | Storage size | Minimum value | Maximum value | Resolution | |||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
timestamp [ (p) ] [ without time zone ] | both date and time (no time zone) | 8 bytes | 4713 bc | 294276 ad | 1 microsecond / 14 digits | |||||||||||||||||||||||||||||||||||||||||||||||||||||
timestamp [ (p) ] with time zone | both date and time, with time zone | 8 bytes | 4713 bc | 294276 ad | 1 microsecond / 14 digits | |||||||||||||||||||||||||||||||||||||||||||||||||||||
date | date (no time of day) | 4 bytes | 4713 bc | 5874897 ad | 1 day | |||||||||||||||||||||||||||||||||||||||||||||||||||||
time [ (p) ] [ without time zone ] | time of day (no date) | 8 bytes | 00:00:00 | 24:00:00 | 1 microsecond / 14 digits | |||||||||||||||||||||||||||||||||||||||||||||||||||||
time [ (p) ] with time zone | times of day only, with time zone | 12 bytes | 00:00:00+1459 | 24:00:00-1459 | 1 microsecond / 14 digits | |||||||||||||||||||||||||||||||||||||||||||||||||||||
interval [ fields ] [ (p) ] | time interval | 12 bytes | -178000000 years | 178000000 years | 1 microsecond / 14 digits |