D
D
Denis Karakchiev2019-01-18 16:42:47
PostgreSQL
Denis Karakchiev, 2019-01-18 16:42:47

Where can I find information about the :: sign in postgresql?

I'm trying to cast data types with it (`number::int`, `number::serial`), but apparently not everything can be cast with it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2019-01-18
@uokersam

https://www.postgresql.org/docs/current/sql-expres...

CAST ( expression AS type )
expression::type
The CAST syntax conforms to SQL; the syntax with :: is historical PostgreSQL usage.

Of course, not everything can be included. You cannot convert 'abc' to a number, it's not a number.
To serial, by the way, you will not be able to bring anything. There isn't really such a type, it's syntactic sugar around sequence and int.
You can add your own rules via create cast

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question