PROMPT Creating table RFS_LOG

create table rfs_log(
   msg_id                        varchar2(50),
   flight_id                     number(10),
   uld_no                        varchar2(10),
   no_of_bag                     number(10),
   log_time                      date,
   row_create_time               date,
   row_date_time                 date,
   cuser                         varchar2(30),
   muser                         varchar2(30),
   mterm                         varchar2(64),
   source                        varchar2(8),
   to_be_archived                varchar2(1),
   appn_row_id                   number(18) not null,
   system_id                     number(4) default 0 not null
);


alter table rfs_log add ( constraint rfs_log_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table rfs_log add constraint rfs_log_uk1 unique (msg_id) using index tablespace &1._indexes ;

alter table rfs_log add constraint rfs_log_fk foreign key (flight_id) references flight(flight_id) on delete cascade;

create index rfs_log_sk1 on rfs_log(flight_id) tablespace &1._indexes;

COMMENT ON TABLE RFS_LOG IS 'This table contains a log of the data sent on the RFS interface to a PC';

COMMENT ON COLUMN RFS_LOG.FLIGHT_ID IS  'Flight identifier';
COMMENT ON COLUMN RFS_LOG.LOG_TIME IS  'TIme the log was raised';
COMMENT ON COLUMN RFS_LOG.MSG_ID IS  'Message identifier';
COMMENT ON COLUMN RFS_LOG.NO_OF_BAG IS  'Number of bags';
COMMENT ON COLUMN RFS_LOG.ULD_NO IS  'ULD number';
COMMENT ON COLUMN RFS_LOG.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN RFS_LOG.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN RFS_LOG.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN RFS_LOG.CUSER IS 'The user who created the row';
COMMENT ON COLUMN RFS_LOG.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN RFS_LOG.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN RFS_LOG.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN RFS_LOG.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN RFS_LOG.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
