PROMPT Creating table EMAIL_ADDRESSES

CREATE TABLE email_addresses (
   email_address_id              NUMBER(10,0) NOT NULL ,
   agent_code                    CHAR(5) NOT NULL ,
   email_address                 VARCHAR2(256) NOT NULL ,
   sita_address                  VARCHAR2(1) DEFAULT 'N' 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 email_addresses add ( constraint email_addresses_pk primary key (appn_row_id) using index tablespace &1._indexes);
  
ALTER TABLE email_addresses ADD CONSTRAINT email_addresses_uk1 unique (email_address_id) USING INDEX TABLESPACE &1._indexes; 

ALTER TABLE email_addresses ADD CONSTRAINT email_addresses_uk2 unique (agent_code, email_address) USING INDEX TABLESPACE &1._indexes; 

ALTER TABLE email_addresses ADD CONSTRAINT email_addresses_fk_agents FOREIGN KEY (agent_code) REFERENCES agents (agent_code);

ALTER TABLE email_addresses ADD CONSTRAINT email_addresses_chk1 CHECK (sita_address IN ('Y','N'));    

COMMENT ON TABLE EMAIL_ADDRESSES IS 'This table contains details of the email addresses used in the system';

COMMENT ON COLUMN EMAIL_ADDRESSES.AGENT_CODE IS  'Agent code';
COMMENT ON COLUMN EMAIL_ADDRESSES.EMAIL_ADDRESS IS  'Email address';
COMMENT ON COLUMN EMAIL_ADDRESSES.EMAIL_ADDRESS_ID IS  'Email address identifier';
COMMENT ON COLUMN EMAIL_ADDRESSES.SITA_ADDRESS IS  'Flag to indicate whether the email account has a SITA address';
COMMENT ON COLUMN EMAIL_ADDRESSES.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN EMAIL_ADDRESSES.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN EMAIL_ADDRESSES.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN EMAIL_ADDRESSES.CUSER IS 'The user who created the row';
COMMENT ON COLUMN EMAIL_ADDRESSES.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN EMAIL_ADDRESSES.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN EMAIL_ADDRESSES.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN EMAIL_ADDRESSES.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN EMAIL_ADDRESSES.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
