Should I use cast(x as typename) or x::typename in PostgreSQL?
I was not able to find any documentation for x::typename version of cast except one sentence in documentation ("By default, a cast can be invoked only by an explicit cast request, that is an explicit CAST(x AS typename) or x::typename construct."
Is the only difference that cast(x as typename) is in sql-standard while x::typename is not?
I do prefer x::typename all the time as it is shorter.
x::typename is postgresql specific. If you prefer it and it doesn't have to work on non postgresql databases you can use it.
The manual for casting is here. As you will see there is a third style but it is not recommended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With