CREATE TABLE GRSPARAMFORNOL (
  CDFORNOL VARCHAR2(21) NOT NULL, 
  CDFORNECED VARCHAR2(21) NOT NULL, 
  IDTPIJUFORNOL VARCHAR2(1) NOT NULL, 
  NRINSJUFORNOL VARCHAR2(20) NOT NULL, 
  NMRAZSOCFORNOL VARCHAR2(40) DEFAULT NULL NULL, 
  NMFANTFORNOL VARCHAR2(40) DEFAULT NULL NULL, 
  HRENTRFORNOL VARCHAR2(4) DEFAULT NULL NULL, 
  IDDOMFORNOL CHAR(1) DEFAULT NULL NULL, 
  IDSEGFORNOL CHAR(1) DEFAULT NULL NULL, 
  IDTERFORNOL CHAR(1) DEFAULT NULL NULL, 
  IDQUAFORNOL CHAR(1) DEFAULT NULL NULL, 
  IDQUIFORNOL CHAR(1) DEFAULT NULL NULL, 
  IDSEXFORNOL CHAR(1) DEFAULT NULL NULL, 
  IDSABFORNOL CHAR(1) DEFAULT NULL NULL, 
  IDDIANUTILOL VARCHAR2(1) DEFAULT 'N' NOT NULL, 
  NRORG NUMBER(10) DEFAULT 1 NOT NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NOT NULL, 
  DTINCLUSAO DATE DEFAULT NULL NULL, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL, 
  DTULTATU DATE DEFAULT NULL NULL, 
  NRORGINCLUSAO NUMBER(10) DEFAULT 1 NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT NULL NULL,
  CONSTRAINT PK_GRS_CDFORNOL PRIMARY KEY(CDFORNOL, CDFORNECED)
)
/
ALTER TABLE GRSPARAMFORNOL ADD CONSTRAINT FK_GRS_CDFORNOL FOREIGN KEY (CDFORNECED) REFERENCES GRSPARAMFORN (CDFORNECED)
/
ALTER TABLE GRSPARAMFORNOL ADD CONSTRAINT CKC_IDSEGFORNOL CHECK (IDSEGFORNOL IS NULL OR (IDSEGFORNOL IN ('S','N')))
/
ALTER TABLE GRSPARAMFORNOL ADD CONSTRAINT CKC_IDDIANUTILOL CHECK (IDDIANUTILOL IN ('S','N'))
/
ALTER TABLE GRSPARAMFORNOL ADD CONSTRAINT CKC_IDTPIJUFORNOL CHECK (IDTPIJUFORNOL IN ('F','J','I','O'))
/
ALTER TABLE GRSPARAMFORNOL ADD CONSTRAINT CKC_IDTERFORNOL CHECK (IDTERFORNOL IS NULL OR (IDTERFORNOL IN ('S','N')))
/
ALTER TABLE GRSPARAMFORNOL ADD CONSTRAINT CKC_IDQUAFORNOL CHECK (IDQUAFORNOL IS NULL OR (IDQUAFORNOL IN ('S','N')))
/
ALTER TABLE GRSPARAMFORNOL ADD CONSTRAINT CKC_IDATIVO_GRSPARAMFORNOL CHECK (IDATIVO IN ('S', 'N'))
/
ALTER TABLE GRSPARAMFORNOL ADD CONSTRAINT CKC_IDDOMFORNOL CHECK (IDDOMFORNOL IS NULL OR (IDDOMFORNOL IN ('S', 'N')))
/
ALTER TABLE GRSPARAMFORNOL ADD CONSTRAINT CKC_IDQUIFORNOL CHECK (IDQUIFORNOL IS NULL OR (IDQUIFORNOL IN ('S','N')))
/
ALTER TABLE GRSPARAMFORNOL ADD CONSTRAINT CKC_IDSEXFORNOL CHECK (IDSEXFORNOL IS NULL OR (IDSEXFORNOL IN ('S','N')))
/
ALTER TABLE GRSPARAMFORNOL ADD CONSTRAINT CKC_IDSABFORNOL CHECK (IDSABFORNOL IS NULL OR (IDSABFORNOL IN ('S','N')))
/
CREATE INDEX FK_GRS_CDFORNOL ON GRSPARAMFORNOL (CDFORNECED)