CREATE TABLE TBTALAO_RFID (
    ID INTEGER NOT NULL,
    TALAO_DETALHE_ID INTEGER,
    TALAO_ID INTEGER,
    REMESSA_ID INTEGER,
    RFID VARCHAR(50));

ALTER TABLE TBTALAO_RFID
ADD CONSTRAINT PK_TBTALAO_RFID
PRIMARY KEY (ID);

CREATE SEQUENCE GTBTALAO_RFID;

SET TERM ^ ;

create trigger ttbtalao_rfid_b01i for tbtalao_rfid
active before insert position 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbtalao_rfid,1);
end
^

SET TERM ; ^

CREATE INDEX ITBTALAO_RFID_03
ON TBTALAO_RFID (REMESSA_ID);

CREATE INDEX ITBTALAO_RFID_02
ON TBTALAO_RFID (TALAO_ID);

CREATE INDEX ITBTALAO_RFID_01
ON TBTALAO_RFID (TALAO_DETALHE_ID);

DROP INDEX ITBTALAO_RFID_02;

DROP INDEX ITBTALAO_RFID_03;

ALTER TABLE TBTALAO_RFID DROP TALAO_ID;

ALTER TABLE TBTALAO_RFID DROP REMESSA_ID;

