CREATE TABLE CTRLATUALTAB(
   NMTABELA 		  VARCHAR2(20) NOT NULL,
   DSCHAVE 			  VARCHAR2(100),
   DTULTATU 		  DATE NOT NULL,
   DTINCLUSAO         DATE                  NULL,
   IDATIVO            VARCHAR2(1)           DEFAULT 'S' NOT NULL
       CONSTRAINT CKC_IDATIVO_CTRLATUALTAB CHECK (IDATIVO IN ('S','N')),
   NRORG             NUMBER 	       		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   NRORGINCLUSAO     NUMBER          		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
   CDOPERINCLUSAO    VARCHAR2(12)    		DEFAULT '1' 		NULL,
   NRORGULTATU       NUMBER          		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
   CDOPERULTATU      VARCHAR2(12)    		DEFAULT '1'
)
/

CREATE INDEX CTRLATUALTAB_01 ON CTRLATUALTAB (NMTABELA, DSCHAVE)
/

CREATE INDEX CTRLATUALTAB_02 ON CTRLATUALTAB (NMTABELA)
/

ALTER TABLE CTRLATUALTAB ADD CONSTRAINT UN_CTRLATUALTAB UNIQUE (NMTABELA, DSCHAVE, DTULTATU)
/

DROP TRIGGER DTULTATU_TABEVEVENDGER
/