You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将SQL转换为H2数据库兼容的SQL语句?

转换为H2兼容的SQL版本

针对原SQL的H2适配修改点:

  • 数组类型:把原character varying[]替换为H2支持的VARCHAR[]
  • 模式前缀:H2默认使用PUBLIC模式,可省略public.(若需显式指定,需写成大写PUBLIC.)
  • 语句完整性:补全UPDATE语句末尾的分号
  • 自增主键:H2原生支持GENERATED ALWAYS AS IDENTITY语法,无需调整

以下是完整的H2兼容SQL:

alter table examination_order_details
    add column is_duplicated boolean default false;

alter table medical_certificate
    add column is_reissued boolean default false;

alter table medical_certificate
    add column correction boolean default false;

alter table medical_certificate
    add column harmful_factors VARCHAR[];

alter table examination_order_details
    add column sd_position_id integer;

alter table examination_order_details_history
    add column sd_position_id integer;

alter table examination_order_details
    add constraint examination_order_details_sd_position_id_fkey
        foreign key (sd_position_id) references positions (id);

UPDATE examinations
    SET is_valid = false
    WHERE name_examination LIKE '%-23%';

create table dictionary_harmful_factors
(
    id                       integer primary key generated always as identity,
    name                     varchar not null,
    printable_on_certificate boolean default false
);

insert into dictionary_harmful_factors (name, printable_on_certificate)
VALUES ('praca na wysokości', true),
       ('praca w torach czynnych', true),
       ('praca przy monitorze ekranowym powyżej 4h', false),
       ('kierowanie sam. osobowym do 3,5 t', true),
       ('kierowanie sam. osobowym do 3,5 t z przewozem osób', true),
       ('akcja zima', false);

内容的提问来源于stack exchange,提问作者Przemysław

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 13:00:55