create table dat_m_kessan (
  hasseibi date not null
  , gyono numeric(3) not null
  , denpyoshuruicd character varying(20) not null
  , denpyono numeric(10) not null
  , meisaicd character varying(10) not null
  , rirekino numeric(3) not null
  , karikatakamokucd character varying(20) not null
  , karikatahojokamoku character varying(40)
  , karikatakingaku numeric(15, 3)
  , karikatashohizeiritsu numeric(5, 2)
  , karikatashohizeigaku numeric(15, 3)
  , karikatatekiyo character varying(100)
  , karikatabushocd character varying(20)
  , karikataprojectcd character varying(40)
  , karikatakozacd character varying(14)
  , karikatatorihikisakicd character varying(20)
  , kashikatakamokucd character varying(20) not null
  , kashikatahojokamoku character varying(40)
  , kashikatakingaku numeric(15, 3)
  , kashikatashohizeiritsu numeric(5, 2)
  , kashikatashohizeigaku numeric(15, 3)
  , kashikatatekiyo character varying(100)
  , kashikatabushocd character varying(20)
  , kashikataprojectcd character varying(40)
  , kashikatakozacd character varying(14)
  , kashikatatorihikisakicd character varying(20)
  , biko character varying(100)
  , shanaibiko character varying(100)
  , sakuseiuserid character varying(40) not null
  , sakuseinichiji timestamp(6) with time zone not null
  , koshinuserid character varying(40) not null
  , koshinnichiji timestamp(6) with time zone not null
  , primary key (hasseibi, gyono)
);

insert into mst_system(paramkb,strparam1,strparam2,numparam1,numparam2,dateparam1,dateparam2,naiyo,sakuseiuserid,sakuseinichiji,koshinuserid,koshinnichiji) select 'kanren_hozonsaki','','',null,null,null,null,'関連ファイル保存先パスを文字列設定1に指定','admin',clock_timestamp(),'admin',clock_timestamp() where not exists (select 0 from mst_system where paramkb = 'kanren_hozonsaki');
