CREATE TABLE FCT_ANEXOMEDICAOFAT (	
		NRANEXOMEDICAOFAT NUMBER, 
		NRMEDICAOFATURA   NUMBER, 
		NMARQUIVO 		  VARCHAR2(300), 
		DSCAMINHO 		  VARCHAR2(1000), 
		DSTIPO 			  VARCHAR2(150), 
		VRTAMANHO 		  FLOAT (126),
		NRTIPOANEXO 	  NUMBER,
		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',
			CONSTRAINT CKC_IDATIVO_ANEXOMEDICAOFAT CHECK (IDATIVO IN ('S','N'))
)
/
ALTER TABLE FCT_ANEXOMEDICAOFAT ADD CONSTRAINT PK_FCT_ANEXOMEDICAOFAT PRIMARY KEY (NRANEXOMEDICAOFAT)
/

ALTER TABLE FCT_ANEXOMEDICAOFAT 
  ADD CONSTRAINT FKSM00409MEDICAOFAT_ANEXMEDFAT FOREIGN KEY (NRMEDICAOFATURA)
      REFERENCES FCT_MEDICAOFATURA (NRMEDICAOFATURA)
/
CREATE INDEX SM00409_FK ON FCT_ANEXOMEDICAOFAT (NRMEDICAOFATURA)
/

ALTER TABLE FCT_ANEXOMEDICAOFAT 
  ADD CONSTRAINT FKSM00410TIPOANEXO_ANEXOMEDFAT FOREIGN KEY (NRTIPOANEXO)
      REFERENCES FCT_TIPOANEXO (NRTIPOANEXO)
/
CREATE INDEX SM00410_FK ON FCT_ANEXOMEDICAOFAT (NRTIPOANEXO)
/