-- *** For demos only***

set echo on
set long 10000000
set longchunksize 10000000
set linesize 200
set pagesize 1000


/*== Drop and create a test tablespace and user ==*/


DROP USER moni CASCADE;

DROP TABLESPACE moni_tbs INCLUDING CONTENTS;

CREATE SMALLFILE TABLESPACE MONI_TBS 
   DATAFILE '/u01/app/oracle/oradata/orcl/moni01.dbf' 
   SIZE 100M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE 32767M NOLOGGING 
   EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

CREATE USER moni IDENTIFIED BY moni 
   DEFAULT TABLESPACE moni_tbs TEMPORARY TABLESPACE temp;

GRANT connect, resource, dba to moni;

/*== Drop and create a MONI_TEST table as MONI user ==*/

CONNECT moni/moni

DROP TABLE moni_test purge;

CREATE TABLE moni_test(c number, d varchar2(500));

begin
for i in 1..200000 loop
insert into moni_test values(1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
end loop;
commit;
end;
/

CREATE INDEX moni_test_c_indx on moni_test(c);

/*== Start long running query ==*/

SELECT count(*) FROM moni_test t1, moni_test t2 
 WHERE t1.c=t2.c AND t1.c=1;

