【问题标题】:h2 make a computed column based on present column in tableh2 根据表中的当前列创建一个计算列
【发布时间】:2013-01-30 01:01:00
【问题描述】:

在我看来,我有一个非常奇怪的问题,我希望根据同一张表中的当前列计算现有列。现有的列类型是“DATE”,另一种是“Datetime”。我使用查询“ ALTER TABLE TEST ALTER COLUMN 'date' AS CONVERT('last_date', DATE) ”。 我总是遇到异常:org.h2.jdbc.JdbcSQLException:SQL 语句中的语法错误“ALTER TABLE TEST ALTER COLUMN 'date'[*] AS CONVERT('last_date', DATE)”;预期的“标识符”;...

等待任何想法。

【问题讨论】:

  • 尝试使用双引号代替单引号。

标签: h2


【解决方案1】:

H2 SQL grammar for alter table 不同。试试:

drop table test;
create table test("last_date" timestamp, "date" timestamp);
alter table test alter column "date" timestamp 
    as convert("last_date", date);

或

drop table test;
create table test(last_date timestamp, date timestamp);
alter table test alter column date timestamp 
    as convert(last_date, date);

【讨论】:

    猜你喜欢
    • 2022-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-10
    • 1970-01-01
    相关资源
    最近更新 更多