PROMPT Creating table REPORTS

CREATE TABLE reports (
   report_id                     NUMBER(10,0) NOT NULL ,
   report_name                   VARCHAR2(100),
   report_title                  VARCHAR2(100)NOT NULL ,
   printable                     VARCHAR2(1)   DEFAULT 'Y' NOT NULL,
   emailable                     VARCHAR2(1)   DEFAULT 'Y' NOT NULL ,
   enabled_in_hist               VARCHAR2(1)  NOT NULL,
   enabled_in_expired            VARCHAR2(1)  NOT NULL,
   parent_report_id              NUMBER(10,0),
   ordinal                       NUMBER(10,0) NOT NULL,
   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 reports add ( constraint reports_pk primary key (appn_row_id) using index tablespace &1._indexes);

ALTER TABLE reports ADD CONSTRAINT reports_uk1 unique ( report_id ) USING INDEX TABLESPACE &1._indexes; 
 
ALTER TABLE reports ADD CONSTRAINT reports_chk1 CHECK (printable IN ('Y','N'));

ALTER TABLE reports ADD CONSTRAINT reports_chk2 CHECK (emailable IN ('Y','N'));

ALTER TABLE reports ADD CONSTRAINT reports_chk3 CHECK (enabled_in_hist IN ('Y','N')  AND enabled_in_expired IN ('Y','N') );

COMMENT ON TABLE REPORTS IS 'This table contains information about the reports used by the system';

COMMENT ON COLUMN REPORTS.EMAILABLE IS  'Indicates whether the report can be emailed';
COMMENT ON COLUMN REPORTS.ENABLED_IN_EXPIRED IS  'Indicates that the report is available for expired data';
COMMENT ON COLUMN REPORTS.ENABLED_IN_HIST IS  'Indicates that the report is available in the history schema';
COMMENT ON COLUMN REPORTS.ORDINAL IS  'Ordinal';
COMMENT ON COLUMN REPORTS.PARENT_REPORT_ID IS  'The report identifier of the parent report';
COMMENT ON COLUMN REPORTS.PRINTABLE IS  'Indicates whether the report is printable';
COMMENT ON COLUMN REPORTS.REPORT_ID IS  'Report identifier';
COMMENT ON COLUMN REPORTS.REPORT_NAME IS  'The name fo the report';
COMMENT ON COLUMN REPORTS.REPORT_TITLE IS  'The title of the report';
COMMENT ON COLUMN REPORTS.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN REPORTS.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN REPORTS.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN REPORTS.CUSER IS 'The user who created the row';
COMMENT ON COLUMN REPORTS.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN REPORTS.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN REPORTS.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN REPORTS.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN REPORTS.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
