CREATE TABLE MPEC.T_MPEC_MARS AS 
SELECT * FROM MPEC.T_MPEC;
ALTER TABLE MPEC.T_MPEC_MARS RENAME COLUMN A_MOPDB_LOAD_SET_FK TO A_WORKFLOW_HISTORY_KEY;
BEGIN
  DBMS_STATS.GATHER_TABLE_STATS(ownname => 'MPEC', tabname => 'T_MPEC_MARS', cascade => TRUE, options => 'GATHER AUTO');
END;
/


CREATE TABLE MPEC.T_MPEC_FULL_MARS AS 
SELECT * FROM MPEC.T_MPEC_FULL;
ALTER TABLE MPEC.T_MPEC_FULL_MARS RENAME COLUMN A_MOPDB_LOAD_SET_FK TO A_WORKFLOW_HISTORY_KEY;
BEGIN
  DBMS_STATS.GATHER_TABLE_STATS(ownname => 'MPEC', tabname => 'T_MPEC_FULL_MARS', cascade => TRUE, options => 'GATHER AUTO');
END;
/


CREATE TABLE MPEC.T_MPEC_MID_FULL_MARS AS 
SELECT * FROM MPEC.T_MPEC_MID_FULL;
ALTER TABLE MPEC.T_MPEC_MID_FULL_MARS RENAME COLUMN A_MOPDB_LOAD_SET_FK TO A_WORKFLOW_HISTORY_KEY;
BEGIN
  DBMS_STATS.GATHER_TABLE_STATS(ownname => 'MPEC', tabname => 'T_MPEC_MID_FULL_MARS', cascade => TRUE, options => 'GATHER AUTO');
END;
/


GRANT SELECT ON MPEC.T_MPEC_MARS TO RQSD WITH GRANT OPTION;
GRANT SELECT ON MPEC.T_MPEC_MARS TO MOPDB_MPEC, MOS_LAB, TEC_MOS_APP;
GRANT DELETE, INSERT, SELECT, UPDATE ON MPEC.T_MPEC_MARS TO MRDS_LOADER;


GRANT SELECT ON MPEC.T_MPEC_FULL_MARS TO MOPDB_MPEC, MOS_LAB, TEC_MOS_APP;
GRANT DELETE, INSERT, SELECT, UPDATE ON MPEC.T_MPEC_FULL_MARS TO MRDS_LOADER;

GRANT SELECT ON MPEC.T_MPEC_MID_FULL_MARS TO MOA_LAB WITH GRANT OPTION;
GRANT INSERT ON MPEC.T_MPEC_MID_FULL_MARS TO MOA_LAB;
GRANT UPDATE ON MPEC.T_MPEC_MID_FULL_MARS TO FOS_LAB;
GRANT DELETE ON MPEC.T_MPEC_MID_FULL_MARS TO MOS_LAB;
GRANT SELECT ON MPEC.T_MPEC_MID_FULL_MARS TO MML_LAB, MOPDB_MPEC, MOS_LAB, TEC_MOS_APP;
GRANT DELETE, INSERT, SELECT, UPDATE ON MPEC.T_MPEC_MID_FULL_MARS TO MRDS_LOADER;
