【问题标题】:What is this type 'literal' syntax in Postgres?Postgres 中的这种“文字”语法是什么?
【发布时间】:2015-06-21 18:20:31
【问题描述】:

Postgres docs 说演员应该看起来像...

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

但这有效:

select date '2015-06-20';

那是什么语法?它记录在哪里?

【问题讨论】:

  • 这是一种(AFAIK SQL 标准)指定任意文字数据类型的方法。例如。 INTEGER '42'.

标签: postgresql casting postgresql-9.4


【解决方案1】:

它是类型常量 - 参见 http://www.postgresql.org/docs/9.4/static/sql-syntax-lexical.html 部分 4.1.2.7。其他类型的常量

可以使用以下任何一种表示法输入任意类型的常量:

输入“字符串” '字符串'::类型 CAST(“字符串”AS 类型)

【讨论】:

    猜你喜欢
    • 2022-11-16
    • 2015-09-24
    • 1970-01-01
    • 1970-01-01
    • 2016-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多