DROP TABLE CARTSUPPLY
/ 

CREATE TABLE CARTSUPPLY (
   NRCARTSUPPLY   NUMBER NOT NULL, 
   CDFILIAL       VARCHAR2(4) NOT NULL,
   CDOPERADOR     VARCHAR2(12) NOT NULL,
   CDFORNECED     VARCHAR2(21),
   IDTIPOCART     VARCHAR2(1) DEFAULT 'P' NOT NULL CONSTRAINT CKC_IDTIPOCART_CARTSUPPLY CHECK (IDTIPOCART IN ('P','I')),
   IDINAUGURA     VARCHAR2(1) DEFAULT 'N' NOT NULL CONSTRAINT CKC_IDINAUGURA_CARTSUPPLY CHECK (IDINAUGURA IN ('N','S')),
   DSADICIONAIS   VARCHAR(200),
   IDSITUCOMPRA   VARCHAR2(1)   CONSTRAINT CKC_IDSITUCOMPRA_CARTSUPPLY CHECK (IDSITUCOMPRA IN ('A','E')),
   NRORG          NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO        VARCHAR2(1) DEFAULT 'S' NOT NULL  CONSTRAINT CKC_IDATIVO_CARTSUPPLY CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO     DATE NULL,
   DTULTATU       DATE 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',
   CONSTRAINT PK_CARTSUPPLY PRIMARY KEY (NRCARTSUPPLY)
)
/

CREATE TABLE PRODCART(
   NRPRODCART     NUMBER NOT NULL,
   NRCARTSUPPLY   NUMBER NOT NULL,
   NRSEQCATALOG   VARCHAR2(200) NOT NULL,   
   CDPRODUTO      VARCHAR2(10) NOT NULL,
   QTPRODUTO      FLOAT NOT NULL,
   VRPRECPROD     FLOAT NOT NULL,
   CDMARCA        VARCHAR2(5) NOT NULL,
   CDFORNECED     VARCHAR2(21),
   CDCATEGORIA    VARCHAR2(3),
   CASUBCATEROGIA VARCHAR2(3),
   NRORG          NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO        VARCHAR2(1) DEFAULT 'S' NOT NULL  CONSTRAINT CKC_IDATIVO_PRODCART CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO     DATE NULL,
   DTULTATU       DATE 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',
   CONSTRAINT PK_PRODCART PRIMARY KEY (NRPRODCART)
)
/

ALTER TABLE AUTOFORNE ADD NRCARTSUPPLY NUMBER
/