create table resevento ( chnfe character varying(50) not null, dhevento character varying(50), tpevento character varying(20) not null, nseqevento integer not null, xevento character varying(100), dhrecbto character varying(50), nprot character varying(30), corgao integer , primary key (chnfe, tpevento, nseqevento) )WITH ( OIDS=FALSE ); ALTER TABLE resnfe OWNER TO postgres; CREATE INDEX index_2 ON resevento USING btree (dhevento, xevento, dhrecbto, nprot, corgao); alter table rescanc add column xmlproceventonfe text; alter table rescanc alter column demi type character varying(30); alter table rescanc alter column dhrecbto type character varying(30); alter table rescce add column xmlrescce text; create table resmanifesto ( chnfe character varying(50), cnpj character varying(14), dhevento character varying(30), tpevento character varying(10) not null, nseqevento integer not null, verevento character varying(10), descevento character varying(50), xmlmanifesto text, nsu character varying(20), primary key (chnfe, tpevento, nseqevento) )WITH ( OIDS=FALSE ); ALTER TABLE resnfe OWNER TO postgres; alter table rescce add column cpf_cnpj character varying(14); alter table resevento add column nsu character varying(15); alter table resevento add column cnpj character varying(14); alter table resevento add column xmlresevento text; alter table resevento add column cpf_cnpj character varying(14); alter table resmanifesto add column cpf_cnpj character varying(14); create table resnfe_outros ( cnpj character varying(20) , nsu character varying(15) , chnfe character varying(44) not null, cpf_cnpj character varying(14) , xnome character varying(100) , ie character varying(14) , demi character varying(20) , tpnf character varying(1) , vnf double precision , digval character varying(30) , dhrecbto character varying(20) , csitnfe integer, csitconf integer, dataconfirmacao date , datadesconhecimento date , datanaorealizada date , dataciencia date , cstatconfirmacao integer, cstatdesconhecimento integer, cstatnaorealizada integer, cstatciencia integer, xmotivoconfirmacao character varying(255) , xmotivodesconhecimento character varying(255) , xmotivonaorealizada character varying(255) , xmotivociencia character varying(255) , dataultimoevento date , csitconfultimoevento integer, cstatultimoevento integer, xmotivoultimoevento character varying(255) , csitconfemcurso integer default '-1', xmlconfirmacao text, xmldesconhecimento text, xmlnaorealizada text, xmlciencia text, xjust character varying(255) , datadownload date , cstatdownload integer, xmotivodownload character varying(255) , xmldownload text, procnfedownload text, xmlretdownload text, dataerrodownload date , primary key (chnfe) )WITH ( OIDS=FALSE ); ALTER TABLE resnfe OWNER TO postgres; CREATE INDEX index_3 ON resnfe_outros USING btree (cnpj,nsu,chnfe,cpf_cnpj,xnome,demi,tpnf,csitnfe,csitconf);