我有一个非常奇怪的问题,我认为,我希望根据同一个表中的当前列来计算现有列。现有列类型为“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)”;预期的“标识符”; ...
等待任何想法。
答案 0 :(得分:3)
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);