CREATE TABLE FCM_ORDENACAOAPP (
	NRORDENCAOAPP  	  NUMERIC  		  NOT NULL,
	CDOPERADOR        VARCHAR2(12) 	  NOT NULL,
	NMTELA         	  VARCHAR2 (1000) NOT NULL,
	NMCAMPO        	  VARCHAR2 (1000) NOT NULL,
	IDSENTIDO    	  VARCHAR2(4) 	  NOT NULL,
	NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    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'
)
/
ALTER TABLE FCM_ORDENACAOAPP ADD CONSTRAINT PK_FCM_ORDENACAOAPP 
	PRIMARY KEY (NRORDENCAOAPP)
/

ALTER TABLE FCM_ORDENACAOAPP ADD CONSTRAINT FKFCM00173_ORDENAAPP_OPERADOR
	FOREIGN KEY (CDOPERADOR) REFERENCES OPERADOR (CDOPERADOR)
/

CREATE INDEX FCM00173_FK ON FCM_ORDENACAOAPP (CDOPERADOR)
/

ALTER TABLE FCM_ORDENACAOAPP ADD CONSTRAINT CHK_IDATIVO_FCM_ORDENACAOAPP CHECK (IDATIVO IN ('S', 'N'))
/