Files
notes/materialized_views/mw03.txt
2026-03-12 22:01:38 +01:00

86 lines
2.1 KiB
Plaintext

-- setup PDB
------------
orapwd file=orapwSITHPRD password="ad420e57a205c9a7d80d!"
create pluggable database NIHILUS admin user NIHILUS$OWNER identified by secret;
alter pluggable database NIHILUS open;
alter pluggable database NIHILUS save state;
alter session set container=NIHILUS;
create user adm identified by "secret";
grant sysdba to adm;
alias NIHILUS='rlwrap sqlplus adm/"secret"@bakura:1521/NIHILUS as sysdba'
create user MASTER identified by secret;
grant connect, resource to MASTER;
grant unlimited tablespace to MASTER;
alias MASTER='rlwrap sqlplus MASTER/"secret"@bakura:1521/NIHILUS'
-- setup PDB
------------
orapwd file=orapwANDOPRD password="oIp757a205c9?jj90yhgf"
create pluggable database RANDOR admin user RANDOR$OWNER identified by secret;
alter pluggable database RANDOR open;
alter pluggable database RANDOR save state;
alter session set container=RANDOR;
create user adm identified by "secret";
grant sysdba to adm;
alias RANDOR='rlwrap sqlplus adm/"secret"@togoria:1521/RANDOR as sysdba'
create user REPLICA identified by secret;
grant connect, resource to REPLICA;
grant create materialized view to REPLICA;
grant create view to REPLICA;
grant create database link to REPLICA;
grant unlimited tablespace to REPLICA;
alias REPLICA='rlwrap sqlplus REPLICA/"secret"@togoria:1521/RANDOR'
-- master site NIHILUS
drop table T1 purge;
create table T1 (
id number generated always as identity,
n1 number(1),
c1 varchar2(10),
d1 DATE
);
alter table T1 add constraint T1_PK primary key (ID);
-- replica site RANDOR
create database link RANDOR_TO_NIHILUS connect to MASTER identified by "secret" using 'bakura:1521/NIHILUS';
select * from DUAL@RANDOR_TO_NIHILUS;
drop materialized view MW0;
drop materialized view MW1;
drop materialized view MW2;
create materialized view MW0 as select * from T1@RANDOR_TO_NIHILUS where n1=0;
create materialized view MW1 as select * from T1@RANDOR_TO_NIHILUS where n1=1;
create materialized view MW2 as select * from T1@RANDOR_TO_NIHILUS where n1=2;
alter session set NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS';
select max(d1) from MW0;
select max(d1) from MW1;
select max(d1) from MW2;