我想创建一个默认值设置为当前年份的表
CREATE TABLE Date
(
"year" smallint NOT NULL DEFAULT extract(year from current_time)
);
它会抛出错误:
!42000!syntax error, unexpected YEAR in: "select year"
如果我使用mclient运行相同的命令,它可以正常工作。
sql>select extract(year from current_date);
+---------------------+
| second_current_date |
+=====================+
| 2015 |
+---------------------+
1 tuple (0.130ms)
sql>
sql>select "year"(NOW());
+-------------------+
| current_timestamp |
+===================+
| 2015 |
+-------------------+
1 tuple (0.380ms)
我只想要这一年。有没有办法做到这一点?
答案 0 :(得分:0)
看起来你正在尝试提取“年”'从CURRENT_ TIME 当你应该尝试从CURRENT_ DATE
获取它时尝试:
The VM session was aborted.
Result Code: E_FAIL (0x80004005)
Component: SessionMachine
Interface: ISession {7844aa05-b02e-4cdd-a04f-ade4a762e6b7}