Data conversion in the Postgres database

Source: Internet
Author: User
Tags postgres database

After postgres8.3, the default transitions between field data are canceled. If a data transformation is required, in the Postgres database, we can use "::" To convert the field data into a type. The actual "::" is called by the cast function. exactly what fields can be converted between data?

This problem can be answered only by studying the cast function. The information of the cast function is managed in the System Pg_cast table.

through the query we can get the type of the current can be converted to the following table:

Source Type conversion Destination type

int8 Int2
int8 Int4
int8 Float4
int8 Float8
int8 Numeric
Int2 int8
Int2 Int4
Int2 Float4
Int2 Float8
Int2 Numeric
Int4 int8
Int4 Int2
Int4 Float4
Int4 Float8
Int4 Numeric
Float4 int8
Float4 Int2
Float4 Int4
Float4 Float8
Float4 Numeric
Float8 int8
Float8 Int2
Float8 Int4
Float8 Float4
Float8 Numeric
Numeric int8
Numeric Int2
Numeric Int4
Numeric Float4
Numeric Float8
Int4 bool
bool Int4
int8 Oid
Int2 Oid
Oid int8
int8 Regproc
Int2 Regproc
Regproc int8
int8 Regprocedure
Int2 Regprocedure
Regprocedure int8
int8 Regoper
Int2 Regoper
Regoper int8
int8 Regoperator
Int2 Regoperator
Regoperator int8
int8 Regclass
Int2 Regclass
Regclass int8
int8 Regtype
Int2 Regtype
Regtype int8
int8 Regconfig
Int2 Regconfig
Regconfig int8
int8 Regdictionary
Int2 Regdictionary
Regdictionary int8
Text Regclass
varchar Regclass
Bpchar Text
Bpchar varchar
Char Text
Char Bpchar
Char varchar
Name Text
Name Bpchar
Name varchar
Text Char
Bpchar Char
varchar Char
Text Name
Bpchar Name
varchar Name
Char Int4
Int4 Char
Abstime Date
Abstime Time
Abstime Timestamp
Abstime Timestamptz
Reltime Interval
Date Timestamp
Date Timestamptz
Time Interval
Time Timetz
Timestamp Abstime
Timestamp Date
Timestamp Time
Timestamp Timestamptz
Timestamptz Abstime
Timestamptz Date
Timestamptz Time
Timestamptz Timestamp
Timestamptz Timetz
Interval Reltime
Interval Time
Timetz Time
Lseg Point
Path Point
Path Polygon
Box Point
Box Lseg
Box Polygon
Box Circle
Polygon Point
Polygon Path
Polygon Box
Polygon Circle
Circle Point
Circle Box
Circle Polygon
inet Cidr
int8 Bit
Int4 Bit
Bit int8
Bit Int4
Cidr Text
inet Text
bool Text
Text Xml
Cidr varchar
inet varchar
bool varchar
varchar Xml
Cidr Bpchar
inet Bpchar
bool Bpchar
Bpchar Xml
Bpchar Bpchar
varchar varchar
Time Time
Timestamp Timestamp
Timestamptz Timestamptz
Interval Interval
Timetz Timetz
Bit Bit
Varbit Varbit
Numeric Numeric

Data conversion in the Postgres database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.