Skip to main content

Casting

Certain data types can be cast to and from other types implicitly or explicitly.

  • Implictly cast to: Values can be automatically converted to the target type.
  • Assigned to: Values can be automatically converted when inserted to a column of the target type.
  • Explictly cast to: Values can be converted to the target type only when you use the cast function or the :: operator.
From typeImplictly cast toAssigned toExplictly cast to
booleanvarchar
integer
smallintinteger
bigint
numeric
real
double
rw_int256
varchar
integerbigint
numeric
real
double
rw_int256
smallintboolean
bigintnumeric
real
double
rw_int256
smallint
integer
varchar
numericreal
double
smallint
integer
bigint
varchar
realdoublesmallint
integer
bigint
numeric
varchar
doublesmallint
integer
bigint
numeric
real
varchar
varcharboolean
smallint
integer
bigint
numeric
real
double
date
timestamp
timestamp with time zone
time
interval
bytea
jsonb
rw_int256
datetimestamp
timestamp with time zone
varchar
timestamptimestamp with time zonevarchar
date
time
timestamp with time zonevarchar
date
timestamp
time
timeintervalvarchar
intervalvarchar
time
byteavarchar
jsonbboolean
smallint
integer
bigint
numeric
real
double
varchar
rw_int256varchar
note

Structs can be casted to structs explictly or implicitly if the nested expressions and types can be casted.

Help us make this doc better!

Was this page helpful?

Happy React is loading...