1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
PostgreSQL Type Description Diesel Type Rust Type
Nullable Types nullable Nullable<T> Option<T>
Numeric Types
smallint, int2 signed integer SmallInt i16
integer, int, int4 signed integer Integer i32
bigint, int8 signed integer BigInt i64
numeric(p, s), decimal(p, s) exact numeric of selectable precision Numeric bigdecimal::BigDecimal
real, float4 single precision floating-point number Float f32
double precision, float8 double precision floating-point number Double f64
smallserial, serial2 autoincrementing integer SmallInt i16
serial, serial4 autoincrementing integer Integer i32
bigserial, serial8 autoincrementing integer BigInt i64
Monetary Types
money currency amount Money Cents
Character Types
character varying(n), varchar(n) variable-length character string Text String, &str
character(n), char(n) fixed-length character string Text String, &str
text variable-length character string Text String, &str
Binary Data Types
bytea binary data (“byte array”) Binary Vec<u8>, &u8
Date/Time Types
timestamp, timestamp(p) without time zone date and time of day Timestamp chrono::NaiveDateTime
timestamptz, timestamp(p) with time zone date and time of day, with time zone Timestamptz chrono::DateTime
date calendar date (year, month, day) Date chrono::NaiveDate
time, time(p) without time zone time of day (no date) Time chrono::NaiveTime
timetz, time(p) with time zone time of day (no date), with time zone
interval(fields)(p) time span Interval PgInterval
Boolean Type
boolean, bool logical Boolean (true/false) Bool bool
Geometric Types
point (x,y) geometric point on a plane
line {A,B,C} infinite line on a plane
lseg ((x1,y1),(x2,y2)) finite line segment on a plane
box ((x1,y1),(x2,y2)) rectangular box on a plane
path ((x1,y1),...) closed geometric path on a plane
path [(x1,y1),...] open geometric path on a plane
polygon ((x1,y1),...) closed geometric path on a plane
circle <(x,y),r\> circle on a plane
Network Address Types
cidr IPv4 or IPv6 network address Cidr ipnetwork::IpNetwork
inet IPv4 or IPv6 host address Inet ipnetwork::IpNetwork
macaddr MAC address MacAddr [u8; 6]
macaddr8 MAC address (EUI-64 format)
Enumerated Types
enum enumerated value (user-defined) String, enum
Bit String Types
bit(n) fixed-length bit string
bit varying(n), varbit variable-length bit string
Text Search Types
tsvector text search document TsVector
tsquery text search query TsQuery
UUID Type
uuid universally unique identifier Uuid uuid::Uuid
XML Type
xml XML data
JSON Types
json textual JSON data Json serde_json::Value
jsonb binary JSON data, decomposed Jsonb serde_json::Value
Arrays
t[] array of values Array<T> Vec<T>, Vec<Option<T>>, &[T], &[Option<T>]
Range Types
int4range range of integer Range<Integer> (Bound<i32>, Bound<i32>)
int8range range of bigint Range<BigInt> (Bound<i64>, Bound<i64>)
numrange range of numeric Range<Numeric> (Bound<bigdecimal::BigDecimal>, Bound<bigdecimal::BigDecimal>)
tsrange range of timestamp Range<Timestamp> (Bound<chrono::NaiveDateTime>, Bound<chrono::NaiveDateTime>)
tstzrange range of timestamptz Range<Timestamptz> (Bound<chrono::DateTime>, Bound<chrono::DateTime>)
daterange range of date Range<Date> (Bound<chrono::NaiveDate>, Bound<chrono::NaiveDate>)
|