· 4 years ago · Feb 18, 2021, 11:00 AM
1if not exists (select 1 from systable where table_name = 'PXVehicleType' and creator = user_id('DBA')) then
2 create table dba.PXVehicleType (
3 TypeID varchar(15) primary key,
4 "Description" varchar(50) null default '',
5 Last_Modified timestamp not null default timestamp
6 ) in system;
7end if;
8
9if not exists (select 1 from systable where table_name = 'PXVehicleGroupHdr' and creator = user_id('DBA')) then
10 create table dba.PXVehicleGroupHdr (
11 TypeGroupHdrID varchar(15) primary key,
12 "Description" varchar(50) null default '',
13 Last_Modified timestamp not null default timestamp
14 ) in system;
15end if;
16
17if not exists (select 1 from systable where table_name = 'PXVehicleGroupDtl' and creator = user_id('DBA')) then
18 create table dba.PXVehicleGroupDtl (
19 TypeGroupHdrID varchar(15) not null,
20 TypeID varchar(15) not null,
21 Last_Modified timestamp not null default timestamp,
22 primary key(TypeGroupHdrID asc, TypeID asc)
23 ) in system;
24
25 alter table dba.PXVehicleGroupDtl
26 add constraint PXVehicleGroupDtl_Reference_PXVehicleGroupDtl foreign key (TypeGroupHdrID) references dba.PXVehicleGroupHdr (TypeGroupHdrID);
27
28 alter table dba.PXVehicleGroupDtl
29 add constraint PXVehicleGroupDtl_Reference_PXVehicleType foreign key (TypeID) references dba.PXVehicleType (TypeID);
30end if;