What is this type 'literal' syntax in Postgres?

1.6k views Asked by At

The Postgres docs say a cast should look like...

expression::typename
typename(expression)
cast(expression as typename)

But this works:

select date '2015-06-20';

What is that syntax? Where is it documented?

1

There are 1 answers

0
Pavel Stehule On BEST ANSWER

It is typed constant - see http://www.postgresql.org/docs/9.4/static/sql-syntax-lexical.html section 4.1.2.7. Constants of Other Types.

A constant of an arbitrary type can be entered using any one of the following notations:

type 'string'
'string'::type
CAST ( 'string' AS type )