-- Licensed Materials - Property of IBM
--
-- BI and PM: CM
--
-- (C) Copyright IBM Corp. 2008, 2020
--
-- US Government Users Restricted Rights - Use, duplication or disclosure
-- restricted by GSA ADP Schedule Contract with IBM Corp.

-- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
-- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).


create table CMOBJECTS (
	CMID			number(10) not null,
	PCMID			number(10) not null,
	VERSION			number(10) default (1) not null,
	CREATED			timestamp not null,
	MODIFIED		timestamp not null,
	DISABLED		number(3) null,
	CLASSID			number(10) not null ,
	DISPSEQ			number(10) default(0) not NULL, 
	OWNER			number(10) null,
	TENANTID		number(10) default(0) not NULL,
	constraint PK_CMOBJECTS primary key (CMID),
	constraint FK_PARENT foreign key (PCMID) references CMOBJECTS(CMID)
);

create index IDX_CLASS on CMOBJECTS(CLASSID);

create index IDX_CLASS1 on CMOBJECTS(CMID, CLASSID);

create index IDX_PARENT on CMOBJECTS(PCMID);

create index IDX_CREATED on CMOBJECTS(CREATED);

create table CMOBJNAMES_BASE (
	CMID			number(10) not null,
	LOCALEID		number(5) not null,
	MAPDLOCALEID	number(5),
	NAME			varchar2(768) not null,
	ISDEFAULT		number(1) default(0) not null,
	constraint PK_CMOBJNAMES primary key (CMID, LOCALEID)
);

create view CMOBJNAMES as select CMID, LOCALEID, MAPDLOCALEID, NAME, ISDEFAULT from CMOBJNAMES_BASE;

create or replace trigger CMOBJNAMES_INSORUPD_TR  instead of insert on CMOBJNAMES 
begin
	update CMOBJNAMES_BASE set NAME=:new.NAME, MAPDLOCALEID=:new.MAPDLOCALEID where CMID=:new.CMID and LOCALEID=:new.LOCALEID;
	if	(sql%rowcount = 0) then
		insert into CMOBJNAMES_BASE (CMID, LOCALEID, NAME, MAPDLOCALEID, ISDEFAULT) values (:new.CMID, :new.LOCALEID, :new.NAME, :new.MAPDLOCALEID, :new.ISDEFAULT);
	end if;
end;
/

create table CMDATA (
	CMID			number(10) not null ,
	CONTENTTYPE		varchar2 (256) null ,
	DATASIZE		number(20),
	DATACOMP		number(1) default(0) not null,
	DATAPROP		blob null, 
	DATAURI			varchar2 (256) null,
	RESOURCETYPE	varchar2 (32) null,
	constraint PK_CMDATA primary key (CMID)
) CMSCRIPT_CMDATA;

CREATE TABLE CMARCHIVESTATUS (
	CMID			number(10) not null,
	ARCHSTAT		number(3) default(0) not NULL, 
	CONSTRAINT PK_CMARCHIVESTATUS PRIMARY KEY (CMID)
);

CREATE TABLE CMSTOREIDS (
	CMID        number(10) NOT NULL,
	STOREID     char(33) NULL,
	CONSTRAINT PK_CMSTOREIDS PRIMARY KEY (CMID)
);

create table CMOBJPROPS1 (
	CMID			number(10) NOT NULL ,
	BUSPHONE		varchar2 (32) NULL ,
	COMMONNAME		varchar2 (192) NULL ,
	EMAIL			varchar2 (384) NULL ,
	FAXPHONE		varchar2 (32) NULL ,
	GIVENNAME		varchar2 (192) NULL ,
	HOMEPHONE		varchar2 (32) NULL ,
	MOBILEPHONE		varchar2 (32) NULL ,
	PAGERPHONE		varchar2 (32) NULL ,
	PADDRESS		varchar2 (768) NULL ,
	SURNAME			varchar2 (192) NULL ,
	TIMEZONE		varchar2 (192) NULL ,
	CLOCALEID		number 	(5) NULL ,
	PRODLOCALE		varchar2 (64) NULL ,
	OBJID			varchar2 (1024) NULL,
	USEACCESSIBILITY	number(1) default(0) NOT NULL,
	USERNAME		varchar2 (192) NULL,
	ORIENTATION		number(3) NULL ,
	HORIZRENDERLIMIT	number(10) null,
	VERTRENDERLIMIT		number(10) null,
	MOBILEDEVID		varchar2 (768) NULL ,
	NOTIFICATIONEMAIL	varchar2 (768) NULL ,
	CONSTRAINT PK_CMOBJPROPS1 PRIMARY KEY (CMID)
);

CREATE TABLE CMOBJPROPS10 (
	CMID			number(10) NOT NULL ,
	CONTACTEMAIL	varchar2 (128) NULL ,
	CONTACT			varchar2 (4000) NULL, 
	CONSTRAINT PK_CMOBJPROPS10 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS11 (
	CMID			number(10) NOT NULL ,
	STATUSID		number(3) NULL,
	EVENTID			varchar2(45) null,
	OWNEREVENTID		varchar2(45) null,
	DISPATCHERID		varchar2 (50) null,
	MAXDETAILSEVTY		number(3) null,
	SCHEDTRIGNAME		varchar2(768) null,
	SCHEDTYPE		number(3) null,
	RESTARTEVENTID		varchar2(45) null,
	CONSTRAINT PK_CMOBJPROPS11 PRIMARY KEY (CMID) 
);

create index IDX_CMOWNEREVENTID on CMOBJPROPS11(OWNEREVENTID);

create index IDX_CMRESTARTID on CMOBJPROPS11(RESTARTEVENTID);

CREATE TABLE CMOBJPROPS13 (
	CMID			number(10)	not NULL,
	ORD				number(10) not null,
	PARMNAME		varchar2(768) not null,
	CPARMVALUE		blob null,
	constraint PK_CMOBJPROPS13 primary key (CMID, ORD)
) lob (CPARMVALUE) store as (enable storage in row);

CREATE TABLE CMOBJPROPS14 (
	CMID			number(10) NOT NULL ,
	RELATED			clob NULL,
	MYPAGE			clob null,
	RETENTION		clob null,
	RECIPSEMAIL		clob NULL,
	CONSTRAINT PK_CMOBJPROPS14 PRIMARY KEY (CMID) 
);

create table CMOBJPROPS15 (
	CMID			number(10) NOT NULL,
	BRSHIAFFINECONS	number(10) null,
	BRSAFFINECONS		number(10) null,
	BRSMAXPROCS		number(10) null,
	METADATAMODEL	varchar2(4000) null,
	BRSEXECTIMELIMIT	number(10) null,
	BRSDATASOURCECHG	timestamp null,
	constraint PK_CMOBJPROPS15 primary key (CMID)
);

create table CMOBJPROPS16 (
	CMID			number(10) not null,
	RSHIAFFINECONS	number(10) null,
	RSAFFINECONS		number(10) null,
	RSMAXPROCS		number(10) null,
	RSQUEUELIMIT		number(10) null,
	RUNNINGSTATE	number(3) null,
	ADVSETTINGS		varchar2(4000) null,
	RSEXECTIMELIMIT	number(10) null,
	ROUTINGTABLE	blob NULL,
	constraint PK_CMOBJPROPS16 primary key (CMID)
);

create table CMOBJPROPS17 (
	CMID				number(10) not null,
	NONPEAKBEGINHOUR	number(3) null,
	NONPEAKMAXJOBS		number(10) null,
	PEAKBEGINHOUR		number(3) null,
	PEAKMAXJOBS			number(10) null,
	NEWNONPEAKBEGINHOUR	number(3) null,
	NEWNONPEAKMAXJOBS		number(10) null,
	NEWPEAKBEGINHOUR		number(3) null,
	NEWPEAKMAXJOBS			number(10) null,
	USERCAPABILITY		number(3) null,
	STARTACTIVE			number(1) null,
	COMPONENTID 		number(3) null,
	PREVIMGLOCATION		varchar2(768) NULL,
	RESRCELOCATION		varchar2(768) NULL,
	constraint PK_CMOBJPROPS17 primary key (CMID)
);

create table CMOBJPROPS18 (
	CMID				number(10) not null,
	OUTPUTREFS			clob null,
	PATHS				clob null,
	constraint PK_CMOBJPROPS18 primary key (CMID)
);

CREATE TABLE CMOBJPROPS2 (
	CMID			number(10) NOT NULL ,
	TASKID			varchar2 (96) NULL ,
	STARTDATE		timestamp NULL ,
	ENDDATE			timestamp NULL ,
	ENDTYPE			number(3) NULL ,
	EVERYNPERIODS	number(10) NULL ,
	DAILYPERIOD		number(3) NULL ,
	MONTHLYABSDAY	number(3) NULL ,
	MONTHLYRELDAY	number(3) NULL ,
	MONTHLYRELWEEK	number(3) NULL ,
	TYPE			number(3) NULL ,
	YEARLYABSDAY	number(3) NULL ,
	YEARLYABSMONTH	number(3) NULL ,
	YEARLYRELDAY	number(3) NULL ,
	YEARLYRELMONTH	number(3) NULL ,
	YEARLYRELWEEK	number(3) NULL ,
	ACTIVE			number(1) default(0) NOT NULL,
	WEEKLYMONDAY	number(1) default(0) NOT NULL ,
	WEEKLYTUESDAY	number(1) default(0) NOT NULL ,
	WEEKLYWEDNESDAY	number(1) default(0) NOT NULL ,
	WEEKLYTHURSDAY	number(1) default(0) NOT NULL ,
	WEEKLYFRIDAY	number(1) default(0) NOT NULL ,
	WEEKLYSATURDAY	number(1) default(0) NOT NULL ,
	WEEKLYSUNDAY	number(1) default(0) NOT NULL, 
	PRIORITY	number(10) NULL,
	INTRARECURSTART		char (13) null,
	INTRARECUREND		char (13) null,
	INTRARECURINTERVAL	varchar2 (50) null,	
	CONSTRAINT PK_CMOBJPROPS2 PRIMARY KEY (CMID) 
);

create index IDX_PRIORITY on CMOBJPROPS2(PRIORITY);

create index IDX_TASKID on CMOBJPROPS2(TASKID);

create table CMOBJPROPS20 (
	CMID                number(10) not null,
	EXECLOCALEID        number(5) null,
	EXECFORMAT          number(3) null,
	EXECPAGEORIENT      number(3) null,
	EXECPROMPT          number(1) default(1) not null,
	DEFPORTACT          number(3) null,
	ALLOWSUBSCRIBE      number(1) null,
	ALLOWNOTIFICATION   number(1) null,
	OBJREFS             clob null,
	constraint PK_CMOBJPROPS20 primary key (CMID)
);

create table CMOBJPROPS23 (
	CMID			number(10) not null,
	LSAUDITADMINLVL	number(3) null,
	LSAUDITLVL		number(3) null,
	LSAUDITOTHERLVL	number(3) null,
	LSAUDITUSAGELVL	number(3) null,
	LSAUDITNATIVEQRY	number(1) NULL,
	QSRMEMCACHEROOT   varchar2(256) null,
	constraint PK_CMOBJPROPS23 primary key (CMID)
);

create table CMOBJPROPS24 (
	CMID			number(10) not null,
	LOCATION		varchar2(512) null,
	MODELNAME		varchar2(256) null,
	PRINTERADDRESS	varchar2(2048) null,
	constraint PK_CMOBJPROPS24 primary key (CMID)
);

create table CMOBJPROPS25 (
	CMID				number(10) not null,
	DEPLOYOBJECT		varchar2 (4000) null,
	DEPLOYOBJANC		clob null,
	DEPLOYOBJCLASSID	number(10) null ,
	DEPLOYOBJDEFNAME	varchar2(768) null,
	DEPLOYOBJDEFSTATUS	number(3) null,
	DEPLOYOBJUSAGE		number(3) null,
	MESSAGE				blob null,
	constraint PK_CMOBJPROPS25 primary key (CMID)
);

CREATE TABLE CMOBJPROPS26 (
	CMID			number(10) not null,
	DELIVOPTIONS			clob null, 
	constraint PK_CMOBJPROPS26 primary key (CMID)
);

CREATE TABLE CMOBJPROPS27 (
	CMID				number(10) not null,
	CUBECONTNAME			varchar2 (2048) NULL,
	GATEWAY				varchar2 (4000) NULL,
	HASPROMPTS			number(1) default(0) not NULL,
	PPOPTIONS			clob null,
	DATABLOCKS			blob null,
	PPDEFPORTACT			number(3) null,
	constraint PK_CMOBJPROPS27 primary key (CMID)
);

CREATE TABLE CMOBJPROPS28 (
	CMID            	number(10) not null,
	EVENTKEY        	clob NULL,
	EVENTTYPES      	clob NULL,
	FILTERDATAITEM		varchar2(768) NULL,
	PARMASSIGN		blob NULL,
	SEQUENCING		number(3) null,
	ALLOWNOTIFICATION 	number(1) null,
	DEFPORTACTION		number(3) NULL,
	RUNCOND			number(3) null,
	SPEC			clob NULL,
	constraint PK_CMOBJPROPS28 primary key (CMID) 
);

create table CMOBJPROPS3_BASE (
	CMID			number(10) not null ,
	PROPNAME		varchar2(50) not null,
	LOCALEID		number(5) not null,
	VALUE			varchar2 (4000) null ,
	ISDEFAULT		number(1) null,
	MAPDLOCALEID	 	number(5),
	constraint PK_CMOBJPROPS3 primary key (CMID, PROPNAME, LOCALEID) 
);

create view CMOBJPROPS3 as select CMID, PROPNAME, LOCALEID, VALUE, ISDEFAULT, MAPDLOCALEID from CMOBJPROPS3_BASE;

CREATE TABLE CMOBJPROPS30 (
	CMID            number(10) NOT NULL ,
	HANDLE          varchar2(255) NULL,
	BINDING         clob NULL,
	REGISTRATION    clob NULL,
	SERVICEDESCR    clob NULL,
	LAYOUT          clob NULL,
	REQUIREDCAP	clob NULL,
	CANCUSTOMIZE	number(1) null,
	CONTEXT         clob NULL,
	DEPLOYREFS	clob NULL,
	constraint PK_CMOBJPROPS30 primary key (CMID) 
);

CREATE TABLE CMOBJPROPS31 (
	CMID			number(10) not null,
	ASAUDITLVL		number(3) null,
	BRSAUDITLVL		number(3) null,
	CMSAUDITLVL		number(3) null,
	DISPAUDITLVL		number(3) null,
	DSAUDITLVL		number(3) null,
	EMSAUDITLVL		number(3) null,
	JSAUDITLVL		number(3) null,
	MDSAUDITLVL		number(3) null,
	MMSAUDITLVL		number(3) null,
	MSAUDITLVL		number(3) null,
	PACSAUDITLVL		number(3) null,
	PDSAUDITLVL		number(3) null,
	PRSAUDITLVL		number(3) null,
	PSAUDITLVL		number(3) null,
	PTSAUDITLVL		number(3) null,
	RSAUDITLVL		number(3) null,
	SSAUDITLVL		number(3) null,
	BRSAUDITNATIVEQRY	number(1) null,
	RSAUDITNATIVEQRY	number(1) null,
	DISAUDITLVL		number(3) null,
	RSDATASOURCECHG	timestamp null,
	IDSAUDITLVL		number(3) null,
	ISSAUDITLVL		number(3) null,
	IUSAUDITLVL		number(3) null,
	RDSAUDITLVL		number(3) null,
	RDSMAXDATASIZE		number(10) null,
	MBSAUDITLVL		number(3) null,
	DDSAUDITLVL		number(3) null,
	DDSLISPERPRCSR		number(10) null,
	DMSAUDITLVL		number(3) null,
	MISAUDITLVL		number(3) null,
	MDSAFFINECONNECTIONS	number(10) null,
	MDSNONAFFINECONNCTS	number(10) null,
	MDSPEAKCONS		number(10) null,
	MDSPEAKNONAFFINECONNCTS	number(10) null,
	MDSPEAKMAXPROCS 	number(10) null,	
	MDSMAXPROCESSES		number(10) null,	
	MDSEXECUTIONTIMELIMIT	number(10) null,	
	MDSQUEUELIMIT		number(10) null,
	MDINFOURI		varchar2 (4000) NULL,
	DIMSAUDITLVL		number(3) null,
	EVSAUDITLVL		number(3) null,
	GSAUDITLVL		number(3) null,
	AASAUDITLVL         	number(3) null,
	HTSAUDITLVL		number(3) null,
	CMCSAUDITLVL		number(3) null,
	QSAUDITLVL 		number(3) null,
	BCSAUDITLVL 		number(3) null,
	CSAUDITLVL 		number(3) null,
	FSAUDITLVL 		number(3) null,
	STSAUDITLVL		number(3) null,
	ANSAUDITLVL		number(3) null,
	RMDSAUDITLVL		number(3) null,
	IDVIZAUDITLVL		number(3) null,
	REPOSAUDITLVL		number(3) null,
	SACAMAUDITLVL		number(3) null,
	constraint PK_CMOBJPROPS31 primary key (CMID)
);

create table CMOBJPROPS32 (
	CMID			number(10) not null,
	STOREDPROCNAME	varchar2(768) NULL,
	constraint PK_CMOBJPROPS32 primary key (CMID)
);

create table CMOBJPROPS33 (
	CMID           number(10) not null,
	NAME           varchar2(768) null,
	USERID         varchar2(1024) null,
	LASTLOGIN      timestamp null,
	CAPABILITIES   varchar2(64) null,
	LICENSE        number(5) null,
	constraint PK_CMOBJPROPS33 primary key (CMID)
);

create table CMOBJPROPS34 (
	CMID			number(10) NOT NULL,
	ACTION			number(3) NULL,
	BOOKMARKITEM		varchar2(768) NULL,
	BOOKMARKTEXT		varchar2(768) NULL,
	DRILLPARMASSIGN		blob NULL,
	SCOPE			blob NULL,
	SPEC			clob NULL,
	TARGETOPTIONS		clob null, 
	DEPLOYREFS		clob null, 
	constraint PK_CMOBJPROPS34 primary key (CMID)
);


create table CMOBJPROPS35 (
	CMID			number(10) NOT NULL,
	BINDINGNAME		varchar2 (768) null,
	INPUTMESSNAME		varchar2 (768) null,
	OPERATIONNAME		varchar2 (768) null,
	OUTPUTMESSNAME		varchar2 (768) null,
	SERVICENAME		varchar2 (768) null,
	BULKEVENTS		number(1) null,
	constraint PK_CMOBJPROPS35 primary key (CMID)
);

create table CMOBJPROPS36 (
	CMID			number(10) NOT NULL,
	ACTION			number(3) NULL,
	constraint PK_CMOBJPROPS36 primary key (CMID)
);

create table CMOBJPROPS37 (
	CMID                number(10) NOT NULL,
	ROUTINGHINTS        clob NULL,
	PROFILESETTINGS     clob null,
	PROFILERANK         number(10) default(0) not null,
	constraint PK_CMOBJPROPS37 primary key (CMID)
);

create table CMOBJPROPS38 (
	CMID			number(10) NOT NULL ,
	CTITEMCOUNTDEFAULT	number(10) null,
	CTITEMCOUNTLIMIT	number(10) null,
	MBRITEMCOUNTDEFAULT	number(10) null,
	MBRITEMCOUNTLIMIT	number(10) null,
	CONSTRAINT PK_CMOBJPROPS38 PRIMARY KEY (CMID)
);

CREATE TABLE CMOBJPROPS39 (
	PROPID			number(5) NOT NULL,
	CMID			number(10) not null,
	VALUE			number(3) not null
);

create index IDX_CMOBJPROPS39 on CMOBJPROPS39 (CMID);

CREATE TABLE CMOBJPROPS4 (
	CMID			number(10) NOT NULL ,
	HEIGHT			varchar2(20) NULL ,
	WIDTH			varchar2(20) NULL ,
	UNIT			number(3) NULL, 
	CONSTRAINT PK_CMOBJPROPS4 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS40 (
	CMID			number(10) NOT NULL ,
	APPGUID			varchar2 (50) NULL ,
	APPID			varchar2 (768) NULL ,
	APPSTATE		number(3) NULL ,
	APPURL			varchar2 (4000) NULL ,
	CONSTRAINT PK_CMOBJPROPS40 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS41 (
	CMID			number(10) NOT NULL,
	DEPTH			number(10) null,
	ITEMID			varchar2 (768) NULL,
	PARENTID		varchar2 (768) NULL,
	CONSTRAINT PK_CMOBJPROPS41 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS42 (
	CMID			number(10) NOT NULL,
	SPEC			clob NULL,
	CONSTRAINT PK_CMOBJPROPS42 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS43 (
	CMID			number(10) NOT NULL,
	SPEC			clob NULL,
	CONSTRAINT PK_CMOBJPROPS43 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS44 (
	CMID			number(10) NOT NULL,
	RDSGATEWMAPPING		blob NULL,
	CONSTRAINT PK_CMOBJPROPS44 PRIMARY KEY (CMID) 
);

create table CMOBJPROPS45 (
	CMID			number(10) NOT NULL,
	LINK			number(3) NULL,
	constraint PK_CMOBJPROPS45 primary key (CMID)
);

CREATE TABLE CMOBJPROPS46 (
	CMID			number(10) NOT NULL,
	DOCTYPE			varchar2 (768) NULL,
	constraint PK_CMOBJPROPS46 primary key (CMID)
);

CREATE TABLE CMOBJPROPS47 (
	CMID			number(10) NOT NULL,
	SYSTEMMETRIC		number(3) NULL,
	PROPERTIES		blob NULL,
	constraint PK_CMOBJPROPS47 primary key (CMID)
);

CREATE TABLE CMOBJPROPS48 (
	CMID			number(10) NOT NULL,
	ASCONNECTIONS		number(10) null,
	CMSCONNECTIONS		number(10) null,
	DDSCONNECTIONS		number(10) null,
	DISCONNECTIONS		number(10) null,
	DSCONNECTIONS		number(10) null,
	IDSCONNECTIONS		number(10) null,
	ISSCONNECTIONS		number(10) null,
	IUSCONNECTIONS		number(10) null,
	JSCONNECTIONS		number(10) null,
	MBSCONNECTIONS		number(10) null,
	MMSCONNECTIONS		number(10) null,
	PACSCONNECTIONS		number(10) null,
	PDSCONNECTIONS		number(10) null,
	PRSCONNECTIONS		number(10) null,
	PTSCONNECTIONS		number(10) null,
	BRSCHHOTSPOTLIMIT	number(10) null,
	RSCHHOTSPOTLIMIT	number(10) null,
	CAPACITY		float null,
	LOADBALMODE		number(3) null,
	DMSCONNECTIONS		number(10) null,
	MISCONNECTIONS		number(10) null,
	DSCOMPATTACHLIMIT	number(10) null,
	QSDIAGENABLED		number(1) null,
	QSMETENABLED		number(1) null,
	QSQUERYEXECTR		number(1) null,
	QSPLANTRC		number(1) null,
	BCSAFFCONS		number(10) null,
	BCSEXECLMT		number(10) null,
	BCSMAXPROCS		number(10) null,
	BCSNONAFFCONS		number(10) null,
	BCSPEAKAFFCONS		number(10) null,
	BCSPEAKMAXPROCS		number(10) null,
	BCSPEAKNONAFFCONS	number(10) null,
	CSAFFCONS		number(10) null,
	CSEXECLMT		number(10) null,
	CSMAXPROCS		number(10) null,
	CSNONAFFCONS		number(10) null,
	CSPEAKAFFCONS		number(10) null,
	CSPEAKMAXPROCS		number(10) null,
	CSPEAKNONAFFCONS	number(10) null,
	FSAFFCONS		number(10) null,
	FSEXECLMT		number(10) null,
	FSCMAXPROCS		number(10) null,
	FSNONAFFCONS		number(10) null,
	FSPEAKAFFCONS		number(10) null,
	FSPEAKMAXPROCS		number(10) null,
	FSPEAKNONAFFCONS	number(10) null,
	RMDSAFFCONS		number(10) null,
	RMDSEXECLMT		number(10) null,
	RMDSNONAFFCONS		number(10) null,
	RMDSPEAKAFFCONS		number(10) null,
	RMDSPEAKNONAFFCONS	number(10) null,
	DASAUDITLVL		number(3) null,
	RMDSCONS			number(10) null,
	RMDSPEAKCONS		number(10) null,
	QSVERBGCLOGLIMIT	number(10) null,
	QSMDQUERYSIZELIMIT	number(10) null,
	QSGENCOMINNATSQL	number(1) null,
	QSDISVERBGCLOG		number(1) null,
	QSINITNURSESIZE		number(10) null,
	QSNURSESIZELIMIT	number(10) null,
	QSGCPOLICY			number(3) null,
	REPOSCACHEOBJTTL	number(10) null,
	REPOSNUMOBJDISK		number(10) null,
	REPOSNUMOBJMEM		number(10) null,
	MAXSTORESZMB		number(10) null,
	constraint PK_CMOBJPROPS48 primary key (CMID)
);

CREATE TABLE CMOBJPROPS49 (
	CMID			number(10) NOT NULL ,
	URI				varchar2 (4000) NULL ,
	CONSTRAINT PK_CMOBJPROPS49 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS5 (
	CMID			number(10) NOT NULL ,
	ACTEXECTIME		timestamp NULL ,
	ACTCOMPTIME		timestamp NULL ,
	REQEXECTIME		timestamp NULL ,
	USERREF			varchar2 (4000) NULL, 
	DETAILTIME		timestamp NULL ,
	DETAIL			clob NULL,
	SEVERITY		number(3) null,
	DETAILTYPE		varchar2(64) NULL,
	INFO			clob NULL,
	CONSTRAINT PK_CMOBJPROPS5 PRIMARY KEY (CMID) 
);

create index IDX_REQEXECTIME on CMOBJPROPS5(REQEXECTIME);

CREATE TABLE CMOBJPROPS50 (
	CMID            number(10) NOT NULL ,
	CONTEXT         blob NULL,
	CONTEXTCOUNT    number(10) NULL,
	LASTPAGE        varchar2(768) null,
	DATADESCRIPTOR  clob NULL,
	METADATA        blob null,
	constraint PK_CMOBJPROPS50 primary key (CMID) 
);

CREATE TABLE CMOBJPROPS51 (
	CMID                 number(10) NOT NULL ,
	SERVERGROUP          varchar2 (768) null,
	RUNASOWNER           number(1) null,
	CANBURST             number(1) null,
	SCHEDTRIGNAME        varchar2(768) NULL,
	RUNWITHOWNERCAPS     number(1) null,
	QUERYMODE            clob NULL,
	RUNINADVANCEDVIEWER  number(1) null,
	DSMODE               varchar2(4000) null,
	CONSTRAINT PK_CMOBJPROPS51 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS52 (
	CMID             number(10) NOT NULL ,
	CONNECTSTR       varchar2 (2048) null,
	ISOLEVEL         number(3) null,
	QUALIFIER        number(3) null,
	REPLACEMENT      varchar2 (768) null,
	CLOSECONNECTCMD  clob null,
	OPENCONNECTCMD   clob null,
	CLOSESESSCMD     clob null,
	OPENSESSCMD      clob null,
	APITOKEN         clob null,
	NOTIFYONCHANGE   number(1) null,
	CONSTRAINT PK_CMOBJPROPS52 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS53 (
	CMID			number(10) NOT NULL ,
	SEQUENCING		number(3) null,
	CONSTRAINT PK_CMOBJPROPS53 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS54 (
	CMID			number(10) NOT NULL ,
	FORMAT			number(3) null,
	OLOCALEID		number(5) null,
	CONSTRAINT PK_CMOBJPROPS54 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS55 (
	CMID			number(10) NOT NULL ,
	ICONURI			varchar2 (3000) NULL ,
	UCPOLICIES		blob NULL, 
	HIDDEN			number(1) default(0) NOT NULL,
	CONSTRAINT PK_CMOBJPROPS55 PRIMARY KEY (CMID) 
) lob (UCPOLICIES) store as (enable storage in row);

CREATE TABLE CMOBJPROPS56 (
	CMID			number(10) NOT NULL,
	SPEC			clob NULL,
	CONSTRAINT PK_CMOBJPROPS56 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS57 (
	CMID			number(10) NOT NULL,
	SPEC			clob NULL,
	CONSTRAINT PK_CMOBJPROPS57 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS58 (
	CMID			number(10) NOT NULL,
	PDSELISTAXSCACHE	number(10) NULL,
	PDSSHOWCELLANN		number(1)  NULL,
	PDSMAXPROCS		number(10) NULL,
	PPSHIAFFINECONS		number(10) null,
	PPSAFFINECONS		number(10) null,
	PPSAUDITLEVEL		number(3) null,
	PPSQUEUELIMIT		number(10) null,
	PPSEXECTIMELIMIT	number(10) null,
	BRSPDFCHARENC		number(3) null,
	BRSPDFCOMPRSLVL		number(10) null,
	BRSPDFCOMPRSTYPE	number(3) null,
	BRSPDFEMBEDFONTS	number(3) null,
	RSPDFCHARENC		number(3) null,
	RSPDFCOMPRSLVL		number(10) null,
	RSPDFCOMPRSTYPE		number(3) null,
	RSPDFEMBEDFONTS		number(3) null,
	DMSAFFINECONNECTIONS	number(10) null,
	DMSEXECUTIONTIMELIMIT	number(10) null,
	DMSMAXPROCESSES		number(10) null,
	DMSNONAFFINECONNCTS	number(10) null,
	DMSPEAKMAXPROCESSES	number(10) null,
	DMSPEAKNONAFFINECONNCTS	number(10) null,
	DMSQUEUELIMIT		number(10) null,
	PERDOCVERSRETAGE		varchar2 (50) null,
	PERDOCVERSRETCOUNT	number(10) null,
	EDITION			varchar2(20) null,
	EDITIONS		blob null,
	DIMSAFFINECONNECTIONS	number(10) null,
    DIMSEXECUTIONTIMELIMIT	number(10) null,
    DIMSMAXPROCESSES	number(10) null,
    DIMSQUEUELIMIT   	number(10) null,
	GLOSSARYURI				varchar2 (4000) NULL ,
	GSAFFINECONNECTIONS		number(10) null,
	GSEXECUTIONTIMELIMIT	number(10) null,
	GSMAXPROCESSES			number(10) null,
	GSNONAFFINECONNCTS		number(10) null,
	GSPEAKMAXPROCESSES		number(10) null,
	GSPEAKNONAFFINECONNCTS	number(10) null,
	GSQUEUELIMIT			number(10) null,
	GSPEAKCONS			number(10) NULL,
	AASAFFINECONNECTIONS	number(10) null,
    	AASEXECUTIONTIMELIMIT	number(10) null,
    	AASMAXPROCESSES	      number(10) null,
	HTSCOMPTASKLIFE		varchar2 (50) null,
	CMCSHEAPLIM		number(10) null,
	ANSANNOTATIONLIFE	varchar2 (50) null,
	CONSTRAINT PK_CMOBJPROPS58 PRIMARY KEY (CMID) 
);

create table CMOBJPROPS59 (
	CMID			number(10) NOT NULL,
	CONFIGURATION		clob NULL,
	USERINTERFACE		number(3) null,
 	CONSTRAINT PK_CMOBJPROPS59 PRIMARY KEY (CMID)
);

CREATE TABLE CMOBJPROPS6 (
	CMID			number(10) NOT NULL ,
	URI				varchar2 (4000) NULL ,
	TARGET			varchar2 (4000) NULL ,
	STEPOBJECT		varchar2 (4000) NULL ,
	BASE			varchar2 (4000) NULL ,
	OBJECTPATH		varchar2 (4000) NULL ,
	CREDENTIAL		varchar2 (4000) NULL ,
	DISPATCHERPATH	varchar2 (4000) NULL ,
	PAGE			varchar2 (4000) NULL,
	CREDNAMESPACES	varchar2 (4000) null,
	CONSTRAINT PK_CMOBJPROPS6 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS60 (
	CMID            number(10) NOT NULL ,
	CONTEXT         blob NULL,
	CONTEXTCOUNT	number(10) NULL,
	LASTPAGE	varchar2(768) NULL,
	constraint PK_CMOBJPROPS60 primary key (CMID) 
);

CREATE TABLE CMOBJPROPS61 (
	CMID            number(10) NOT NULL ,
	BURSTKEY	varchar2 (4000) NULL,
	constraint PK_CMOBJPROPS61 primary key (CMID) 
);

CREATE TABLE CMOBJPROPS62 (
	CMID            number(10) NOT NULL ,
	EXPIRATION 		timestamp NULL,
	ALLOWANNOTATION 	number(1) null,
	constraint PK_CMOBJPROPS62 primary key (CMID) 	
);

create index IDX_EXPIRATION_62 on CMOBJPROPS62(EXPIRATION);

CREATE TABLE CMOBJPROPS63 (
	CMID			number(10) NOT NULL,
	SPEC			clob NULL,
	CONSTRAINT PK_CMOBJPROPS63 PRIMARY KEY (CMID) 
);

create table CMOBJPROPS64 (
	CMID			number(10) not null ,
	CONTENTTYPE		varchar2 (256) null ,
	DATASIZE		number(20),
	DATACOMP		number(1) default(0) not null,
	DATAPROP		blob null, 
	constraint PK_CMOBJPROPS64 primary key (CMID)
) lob (DATAPROP) store as (enable storage in row);

CREATE TABLE CMOBJPROPS65 (
	CMID            number(10) NOT NULL ,
	BURSTID		varchar2 (4000) NULL,
	BURSTIDINDEX 	char(44) NULL ,
	constraint PK_CMOBJPROPS65 primary key (CMID) 
);

CREATE INDEX IDX_BURSTIDINDEX ON CMOBJPROPS65(BURSTIDINDEX);

CREATE TABLE CMOBJPROPS66 (
	CMID            number(10) NOT NULL ,
	DEFPORTACT	number(3) null,
	SPEC		clob NULL ,
	POWERPLAY8CONFIGURATION clob NULL,
	constraint PK_CMOBJPROPS66 primary key (CMID) 
);

CREATE TABLE CMOBJPROPS67 (
	CMID				number(10) NOT NULL,
	NONPEAKDEMANDBGNH	number(10) NULL,
	PEAKDEMANDBEGINH	number(10) NULL,
	ASPEAKCONS			number(10) NULL,
	BRSPEAKAFFINECONS	number(10) NULL,
	BRSPEAKMAXPROCS		number(10) NULL,
	BRSPEAKNONAFFCONS	number(10) NULL,
	CMSPEAKCONS			number(10) NULL,
	DDSPEAKCONS			number(10) NULL,
	DISPEAKCONS			number(10) NULL,
	DMSPEAKCONS			number(10) NULL,
	DSPEAKCONS			number(10) NULL,
	IDSPEAKCONS			number(10) NULL,
	ISSPEAKCONS			number(10) NULL,
	IUSPEAKCONS			number(10) NULL,
	JSPEAKCONS			number(10) NULL,
	MBSPEAKCONS			number(10) NULL,			
	MISPEAKCONS			number(10) NULL,
	MMSPEAKCONS			number(10) NULL,
	PACSPEAKCONS		number(10) NULL,
	PDSPEAKCONS			number(10) NULL,
	PDSPEAKMAXPROCS		number(10) NULL,
	PPSPEAKAFFINECONS	number(10) NULL,
	PPSPEAKNONAFFCONS	number(10) NULL,
	PRSPEAKCONS			number(10) NULL,
	PTSPEAKCONS			number(10) NULL,
	RSPEAKAFFINECONS	number(10) NULL,
	RSPEAKMAXPROCS		number(10) NULL,
	RSPEAKNONAFFCONS	number(10) NULL,
   	DIMSNONAFFINECONNCTS	number(10) NULL,
   	DIMSPEAKCONS	        number(10) NULL,
   	DIMSPEAKMAXPROCS	number(10) NULL,
   	DIMSPEAKNONAFFINECONNCTS	number(10) NULL,
	TEMPOBJLOCATION		number(3) NULL,
	TEMPOBJLIFETIME		varchar2 (50) null,
   	AASNONAFFINECONNCTS	number(10) NULL,
   	AASPEAKCONS	            number(10) NULL,
   	AASPEAKMAXPROCS	      number(10) NULL,
   	AASPEAKNONAFFINECONNCTS number(10) NULL,
	STSAFFCONS		number(10) NULL,
	STSEXECLMT		number(10) NULL,
	STSCMAXPROCS		number(10) NULL,
	STSNONAFFCONS		number(10) NULL,
	STSPEAKAFFCONS		number(10) NULL,
	STSPEAKMAXPROCS		number(10) NULL,
	STSPEAKNONAFFCONS	number(10) NULL,	
	OVERRIDEOPTS		clob null,
	SERVRDEFOPTS		clob null,
	STSQUEUELIM			number(10) NULL,
	COLLABDISCURI		varchar2 (4000) NULL, 
	BRSMAXATTACHSIZE	number(10) NULL,
	DSMAXATTACHSIZE		number(10) NULL,
	RSMAXATTACHSIZE		number(10) NULL,
	ASMAXATTACHSIZE		number(10) NULL,
	PPSMAXATTACHSIZE	number(10) NULL,
	QSIDLECONTIMEOUT 	number(10) NULL,
	QSDUMPMODEL 		number(1) NULL,
	QSDISPLAN 		number(1) NULL,
	ACTIVEJMXPROXYURI	clob NULL,
	QSADDJVMARG		varchar2 (3072) NULL,
	QSINITJVMHEAP		number(10) NULL,
	QSMANCUBESTRT		number(1) NULL,
	QSMAXJVMHEAP		number(10) NULL,
	QSROLAPCUBECONF		blob NULL,
	QSROLAPCADMINCT		number(10) NULL,
	QSRSETQUERYTHRES		number(10) NULL,
	COOKIECAMPASSHTTP		number(1) NULL,
	constraint PK_CMOBJPROPS67 primary key (CMID) 
);

CREATE TABLE CMOBJPROPS68 (
	CMID            number(10) NOT NULL ,
	SPEC		clob NULL ,
	constraint PK_CMOBJPROPS68 primary key (CMID) 
);


CREATE TABLE CMOBJPROPS69 (
	CMID			number(10)	not NULL,
	ORD				number(10) not null,
	PARMNAME		varchar2(768) not null,
	CPARMVALUE		blob null,
	constraint PK_CMOBJPROPS69 primary key (CMID, ORD)
) lob (CPARMVALUE) store as (enable storage in row);


CREATE TABLE CMOBJPROPS7 (
	CMID			number(10) NOT NULL ,
	EXECERROR		clob NULL ,
	CONFIGURATION	clob NULL ,
	PORTALPREFS		clob NULL ,
	CCREDENTIALS	clob NULL ,
	CMODEL			blob NULL ,
	SRC				clob NULL ,
	SPEC			clob NULL ,
	STATE			clob null,
	GOVERNORS		clob null, 
	NAMESPFORMAT	varchar2 (4000) null,
	CONSTRAINT PK_CMOBJPROPS7 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS70 (
	CMID            number(10) NOT NULL ,
	CONTEXT         clob NULL,
	DEPLOYREFS	clob NULL,
	constraint PK_CMOBJPROPS70 primary key (CMID) 
);

CREATE TABLE CMOBJPROPS71 (
	CMID            number(10) NOT NULL ,
	CONTEXT         clob NULL,
	DEPLOYREFS	clob NULL,
	constraint PK_CMOBJPROPS71 primary key (CMID) 
);

CREATE TABLE CMOBJPROPS72 (
	CMID            number(10) NOT NULL ,
	CONTEXT         clob NULL,
	constraint PK_CMOBJPROPS72 primary key (CMID) 
);


CREATE TABLE CMOBJPROPS73 (
	CMID         number(10)      NOT NULL,
	ALIASROOT    varchar2 (768)  NULL,
	URI          varchar2 (4000) NULL,
	UNIXURI      varchar2 (4000) NULL,
	WINDOWSURI   varchar2 (4000) NULL,
	CONSTRAINT PK_CMOBJPROPS73 PRIMARY KEY (CMID)
);

CREATE TABLE CMOBJPROPS74 (
	CMID		number(10)      NOT NULL,
	DEPLOYREFS	clob 		NULL,
	LAUNCHTYPE	varchar2 (768)  NULL,
	SPEC		blob 		NULL,
	CONSTRAINT PK_CMOBJPROPS74 PRIMARY KEY (CMID)
);

create index IDX_CMLAUNCHTYPE on CMOBJPROPS74(LAUNCHTYPE);

CREATE TABLE CMOBJPROPS75 (
	CMID			number(10)      NOT NULL,
	RESOURCETYPE		varchar2 (768)  NULL,
	SPEC			blob 		NULL,
	CONSTRAINT PK_CMOBJPROPS75 PRIMARY KEY (CMID)
);

create index IDX_CMRESOURCETYPE on CMOBJPROPS75(RESOURCETYPE);

CREATE TABLE CMOBJPROPS76 (
	CMID			number(10)      NOT NULL,
	CONTENTTYPE		varchar2 (768)  NULL,
	CONSTRAINT PK_CMOBJPROPS76 PRIMARY KEY (CMID)
);

CREATE TABLE CMOBJPROPS77 (
	CMID			 number(10) NOT NULL ,
	DSCONNECTIONNAME 	 varchar2 (768) null,
	DSNAME			 varchar2 (768) null,
	CONSTRAINT PK_CMOBJPROPS77 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS78 (
	CMID			number(10)      NOT NULL,
	BINDINGNAME		varchar2 (768)  NULL,
	INPUTMESSNAME		varchar2 (768)  NULL,
	OPERATIONNAME		varchar2 (768)  NULL,
	OUTPUTMESSNAME		varchar2 (768)  NULL,
	SERVICENAME		varchar2 (768)  NULL,
	BULKEVENTS		number(1) null,
	URI			clob 		NULL,
	CONSTRAINT PK_CMOBJPROPS78 PRIMARY KEY (CMID)
);

CREATE TABLE CMOBJPROPS79 (
	CMID         	number(10) not null,
	PUBLISHED	number(1) null,
	SPEC		clob null,
	CONSTRAINT PK_CMOBJPROPS79 PRIMARY KEY (CMID)
);

CREATE TABLE CMOBJPROPS80 (
	CMID              number(10) NOT NULL ,
	REPOSITORYRULES   clob null,
	NSCAPS            clob null,
	CONSTRAINT PK_CMOBJPROPS80 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS81 (
	CMID			number(10) NOT NULL ,
	AGGREGATES		clob null,
	CONSTRAINT PK_CMOBJPROPS81 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS82 (
	CMID			number(10) NOT NULL ,
	BPMRESTURI		varchar2 (4000) NULL ,
	CONSTRAINT PK_CMOBJPROPS82 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS83 (
	CMID			number(10)	not NULL,
	MOBILECONFIG		blob null,
	CONSTRAINT PK_CMOBJPROPS83 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS84 (
	CMID		number(10)	not NULL,
	SPEC		clob null,
	DATASIZE	number(20),
	DATAMODTIME	timestamp NULL,
	CONSTRAINT PK_CMOBJPROPS84 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS85 (
	CMID             number(10) NOT NULL ,
	DATA             clob null,
	DEPLOYREFS       clob null,
	OBJREFS          clob null,
	BIVARS           clob null,
	EMBEDDING        clob null,
	STATUS           clob null,
	USAGETRACKMODEL  clob null,
	CONSTRAINT PK_CMOBJPROPS85 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS86 (
	CMID			number(10) NOT NULL ,
	KSCHEMA			varchar2 (256)  NULL,
	KCATALOG		varchar2 (256)  NULL,
	CPHYSDEF		clob null,
	CPHYSANAL		clob null,
	CBASEDEF		clob null,
	CBASEOVER		clob null,
	CBASEANAL		clob null,
	STATUSID		number(3) NULL,
	SNAPSHOT       	clob null,
	HISTORY       	clob null,
	SNAPSHOTENBL	number(1) NULL,
	DEPLOYREFS		clob null,
	ALIASROOT		varchar2 (256) NULL,
	CONSTRAINT PK_CMOBJPROPS86 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS87 (
	CMID        number(10) NOT NULL ,
	EXT         clob null,
	CONSTRAINT PK_CMOBJPROPS87 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS88 (
	CMID        number(10) NOT NULL ,
	SCHEMATYPE		varchar2 (256) NULL,
	STATUS			varchar2 (256) NULL,
	STATUSINFO		clob NULL,
	CONSTRAINT PK_CMOBJPROPS88 PRIMARY KEY (CMID) 
);

create table CMOBJPROPS89 (
	CMID        number(10) not null,
	DOCTYPE     varchar2(64) not null,
	DOCID       varchar2(64) not null,
	CONTENT     clob null,
	CONSTRAINT PK_CMOBJPROPS89 PRIMARY KEY (CMID)
);

create index IDX_CMPROPS89_1 on CMOBJPROPS89(DOCID);

CREATE TABLE CMOBJPROPS9 (
	CMID			number(10) NOT NULL ,
	ASOFTIME		timestamp NULL, 
	CANBURST		number(1) null,
	CONSTRAINT PK_CMOBJPROPS9 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS90 (
	CMID        number(10) NOT NULL,
	SPEC        clob NULL,
	CONSTRAINT PK_CMOBJPROPS90 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS91 (
	CMID        number(10) NOT NULL,
	SKDATA      clob NULL,
	CONSTRAINT PK_CMOBJPROPS91 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS92 (
	CMID        number(10) NOT NULL,
	CONTYPE     varchar2(64) NULL,
	URI         clob NULL,
	SPEC        clob NULL,
	CONSTRAINT PK_CMOBJPROPS92 PRIMARY KEY (CMID) 
);

CREATE TABLE CMOBJPROPS93 (
	CMID                 number(10) NOT NULL,
	PROGRESS             varchar2(1024) NULL,
	JOBID                varchar2(64) NULL,
	STATE                varchar2(64) NULL,
	CONFIGURATION        clob NULL,
	CONSTRAINT PK_CMOBJPROPS93 PRIMARY KEY (CMID) 
);

CREATE TABLE CMTAGS (
	CMID      number(10) not null,
	ORD       number(10) not null,
	TAG       varchar2(256) null,
	constraint PK_CMTAGS primary key (CMID, ORD)
);

create index IDX_CMTAGS on CMTAGS(CMID, TAG);

CREATE TABLE CMPOLICIES (
	CMID			number(10) NOT NULL ,
	POLICIES		blob NULL, 
	CONSTRAINT PK_CMPOLICIES PRIMARY KEY (CMID) 
) lob (POLICIES) store as (enable storage in row);

CREATE TABLE CMVIEWED (
	CMID			number(10) NOT NULL ,
	OBJID			varchar2 (4000) default ('-') NOT NULL ,
	VIEWED			number(1) default(0) NOT NULL,
	CONSTRAINT PK_CMVIEWED PRIMARY KEY (CMID) 
);

create table CMGUIDS_BASE (
	CMID			number(10) not null,
	GUID			varchar2(50) NULL,
	constraint PK_CMGUIDS primary key (CMID)
);

create view CMGUIDS as select CMID, GUID from CMGUIDS_BASE;

CREATE SEQUENCE guid_seq;

create or replace trigger CMGUIDS_INSERT_TR instead of insert on CMGUIDS
begin
	insert into CMGUIDS_BASE (CMID, GUID) values ( :new.CMID, TO_CHAR(guid_seq.nextval) );
end;
/

create table CMPROPERTIES (
	PROPID			number(5) NOT NULL,
	NAME			varchar2(50) NOT NULL,
	DEF				blob		NULL,
	CONSTRAINT PK_CMPROPERTIES PRIMARY KEY(PROPID)
);

create table CMCLASSES (
	CLASSID			number(10) NOT NULL,
	NAME			varchar2(50) NOT NULL,
	USAGE			number(3)		NULL,
	DEF				blob		NULL,
	CONSTRAINT PK_CMCLASSES PRIMARY KEY(CLASSID)
);

create table CMLOCALES (
	LOCALEID		number(5)		not null,
	MAPDLOCALEID	number(5)		not null,
	LOCALE			varchar2(20)	not null,
	constraint PK_CMLOCALES primary key (LOCALEID)
);

CREATE TABLE  CMREFNOORD1 (
	PROPID			number(5) NOT NULL,
	CMID			number(10) not null,
	REFCMID			number(10) not null,
	constraint PK_CMREFNOORD1 primary key (CMID, PROPID) );

create index IDX_CMREFNOORD1 on CMREFNOORD1(REFCMID, PROPID);

CREATE TABLE  CMREFNOORD2 (
	CMID			number(10) not null,
	REFCMID			number(10) not null,
	constraint PK_CMREFNOORD2 primary key (CMID) );

create index IDX_CMREFNOORD2 on CMREFNOORD2(REFCMID);

CREATE TABLE  CMREFORD1 (
	PROPID			number(5) NOT NULL,
	CMID			number(10) not null,
	ORD			number(10) NOT NULL,
	REFCMID			number(10) not null,
	constraint PK_CMREFORD1 primary key (CMID, PROPID, ORD) );

create index IDX_CMREFORD1 on CMREFORD1(REFCMID, PROPID, ORD);

CREATE TABLE  CMREFORD2 (
	CMID			number(10) not null,
	ORD			number(10) NOT NULL,
	REFCMID			number(10) not null,
	constraint PK_CMREFORD2 primary key (CMID, ORD) );

create index IDX_CMREFORD2 on CMREFORD2(REFCMID, ORD);

CREATE GLOBAL TEMPORARY TABLE CMTMPIDS (
	QUERYID	number(10) not null,
	CMID	number(10) not null
)  ON COMMIT PRESERVE ROWS;

CREATE GLOBAL TEMPORARY TABLE CMTMPCOPYIDS (
	QUERYID	number(10) not null,
	GROUPID	number(10) not null,
	SOURCECMID	number(10) not null,
	TARGETCMID	number(10) not null
)  ON COMMIT PRESERVE ROWS;

create global temporary table CMTMPLOBS (
	LOBID	number(10) not null,
	TMPCLOB	clob,
	TMPBLOB blob
) on commit delete rows;

create view CMOWNERCOUNT(OBJID, OWN_NUMBER) as 
   SELECT p2.OBJID, count(o.CMID)  
   FROM CMOBJECTS o left outer join CMREFNOORD2 p1 on p1.CMID = o.CMID
                    left outer join CMOBJPROPS1 p2 on p1.REFCMID = p2.CMID
   GROUP BY p2.OBJID;

CREATE TABLE CMDATAUPGRADE (
	PLUGINNAME 	varchar2(255) NOT NULL ,
	CI_PLUGINNAME 	varchar2(255) NOT NULL ,
	VERSION		varchar2(64) NULL ,
	CONSTRAINT PK_CMDATAUPGRADE PRIMARY KEY (CI_PLUGINNAME)
);

CREATE TABLE CMSIZEINFO (
	STOREID          varchar2(255) NOT NULL,
	CLASSID          number(10) NOT NULL,
	TOTALFORCLASSID  number(10) NOT NULL ,
	TOTALCOUNT       number(20)  NULL ,
	TOTALSIZE        number(20)  NULL ,
	CONSTRAINT PK_CMSIZEINFO PRIMARY KEY (STOREID, TOTALFORCLASSID)
);

CREATE TABLE CMSPLIT  (
		CMID		number(10) not null,
		TRANSACTIONID	varchar2(255) not null,
		constraint PK_CMSPLIT  primary key (CMID, TRANSACTIONID)
);

CREATE TABLE CMARCHIVEQUEUE (
	OBJID 	 	VARCHAR2(255) NULL,
	ITEMID	 	VARCHAR2(255) NOT NULL,
	QUEUEID		VARCHAR2(255) NOT NULL,
	WORKFLOW 	VARCHAR2(255) NOT NULL,
	CONSUMERNAME	VARCHAR2(255) NULL,
	STATE		number(10),
	INSERTIONTIME 	TIMESTAMP NOT NULL,
	CONSTRAINT PK_CMARCHIVEQUEUE PRIMARY KEY (ITEMID)
);

CREATE TABLE CMDELETEQUEUE (
	OBJID 	 	VARCHAR2(255) NULL,
	ITEMID	 	VARCHAR2(255) NOT NULL,
	QUEUEID		VARCHAR2(255) NOT NULL,
	WORKFLOW 	VARCHAR2(255) NOT NULL,
	CONSUMERNAME	VARCHAR2(255) NULL,
	STATE		number(10),
	INSERTIONTIME 	TIMESTAMP NOT NULL,
	CONSTRAINT PK_CMDELETEQUEUE PRIMARY KEY (ITEMID)
);

CREATE TABLE CMINDEXQUEUE (
	OBJID 	 		VARCHAR2(1024) NULL,
	ITEMID	 		VARCHAR2(50) NOT NULL,
	QUEUEID			VARCHAR2(50) NOT NULL,
	WORKFLOW 		VARCHAR2(50) NOT NULL,
	CONSUMERNAME	VARCHAR2(50) NULL,
	STATE			NUMBER(10),
	INSERTIONTIME 	TIMESTAMP NOT NULL,
	INDEXACTION		VARCHAR2(50) NOT NULL,
	INDEXCLASS		VARCHAR2(255) NOT NULL,
	INDEXPROPS		CLOB NULL,
	CONSTRAINT PK_CMINDEXQUEUE PRIMARY KEY (ITEMID)
);

CREATE INDEX IDX_CMINDEXQUEUE on CMINDEXQUEUE(STATE, QUEUEID);

CREATE TABLE CMQUEUELOCK (
	QUEUEID		VARCHAR2(255) NOT NULL,
	CONSTRAINT PK_CMQUEUELOCK PRIMARY KEY (QUEUEID)
);

CREATE TABLE CMTENANTID (
	TENANTID	NUMBER(10) NOT NULL,
	TENANTNAME	VARCHAR2(255) NULL,
	CONSTRAINT PK_CMTENANTID PRIMARY KEY (TENANTID)
);

INSERT INTO CMTENANTID (TENANTID,TENANTNAME) VALUES (0,'');

INSERT INTO CMSYSPROPS (PROPNAME, CI_PROPNAME, PROPVALUE)
	VALUES ('CMStoreVersion', UPPER('CMStoreVersion'), '7.7003');
