Generate series of dates - using date type as input
1 2 3 4 5 6 | pg=# SELECT generate_series('2014-01-01'::DATE,'2014-01-02'::DATE,'1 day'); generate_series ------------------------ 2014-01-01 00:00:00+01 2014-01-02 00:00:00+01 (2 ROWS) |
由于函数类型解析,我们还可以将
- 生成PostgreSQL中两个日期之间的时间序列
对于裸
Postgres如何确定哪些类型可以接受?
Postgres基本上区分了三种类型的演员表:
系统中必须存在从输入类型到预期类型的??隐式转换,以使函数静默接受(和转换)输入值。
要查看哪些强制转换定义为
1 2 3 4 5 6 7 8 9 10 | SELECT castsource::regtype, casttarget::regtype, castcontext FROM pg_cast WHERE casttarget = 'timestamptz'::regtype; castsource | casttarget | castcontext -----------------------------+--------------------------+------------- abstime | TIMESTAMP WITH TIME zone | i DATE | TIMESTAMP WITH TIME zone | i TIMESTAMP WITHOUT TIME zone | TIMESTAMP WITH TIME zone | i TIMESTAMP WITH TIME zone | TIMESTAMP WITH TIME zone | i |
所有这些演员都是隐含的。关于
Indicates what contexts the cast can be invoked in.
e means only as an
explicit cast (usingCAST or:: syntax).a means implicitly in
assignment to a target column, as well as explicitly.i means
implicitly in expressions, as well as the other cases.
大胆强调我的。