CREATE TABLE TBSPED_REINF (
    ID INTEGER NOT NULL,
    ESTABELECIMENTO_ID INTEGER,
    PERIODO DATE,
    FORMA_EMISSAO INTEGER,
    FISCAL_CONTADOR_ID INTEGER,
    DATAHORA TIMESTAMP DEFAULT 'NOW');

ALTER TABLE TBSPED_REINF
ADD CONSTRAINT PK_TBSPED_REINF
PRIMARY KEY (ID);


CREATE SEQUENCE GTBSPED_REINF;

create trigger ttbsped_reinf_b01i for tbsped_reinf
active before insert position 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbsped_reinf,1);
end;


CREATE INDEX ITBSPED_REINF_01
ON TBSPED_REINF (ESTABELECIMENTO_ID);

CREATE INDEX ITBSPED_REINF_02
ON TBSPED_REINF (PERIODO);

CREATE INDEX ITBSPED_REINF_03
ON TBSPED_REINF (FISCAL_CONTADOR_ID);