CREATE SMALLFILE TABLESPACE TS_DATA 
    DATAFILE 
        'C:\ORACLE\PRODUCT\21C\ORADATA\XE\XEPDB1\TS_DATA.DBF' SIZE 3221225472 AUTOEXTEND ON NEXT 52428800 MAXSIZE UNLIMITED 
    BLOCKSIZE 8192 
    DEFAULT NOCOMPRESS NO INMEMORY
    ONLINE 
    SEGMENT SPACE MANAGEMENT AUTO 
    EXTENT MANAGEMENT LOCAL AUTOALLOCATE;

CREATE USER "SSB"
IDENTIFIED BY ssb
DEFAULT TABLESPACE "TS_DATA"
TEMPORARY TABLESPACE "TEMP"
ACCOUNT UNLOCK ;

grant dba to ssb;

imp ssb/ssb@localhost/xepdb1 file=ssb.dmp full=yes


begin DBMS_STATS.GATHER_SCHEMA_STATS (
	  ownname => 'SSB',
          estimate_percent => 100
          );
          end;


connect / as sysdba

alter system set sga_target=1568M scope=spfile;

alter system set pga_aggregate_target=412M scope=spfile;

alter system set inmemory_size=1073741824 scope=spfile;

shutdown immediate

startup

show sga

connect ssb/ssb@localhost/xepdb1


-- On Demand Population - Default INMEMORY PRIORITY is set to NONE

alter table CUSTOMER inmemory;
alter table DATE_DIM inmemory;
alter table LINEORDER inmemory;
alter table PART inmemory;
alter table SUPPLIER inmemory;


-- Alternatively, INMEMORY PRIORITY is set to CRITICAL and HIGH

alter table CUSTOMER inmemory priority high;
alter table DATE_DIM inmemory priority high;
alter table LINEORDER inmemory priority critical;
alter table PART inmemory priority high;
alter table SUPPLIER inmemory priority high;



select /*+ INMEMORY */
  sum(lo_extendedprice * lo_discount) revenue
from
  LINEORDER l,
  DATE_DIM d
where
  l.lo_orderdate = d.d_datekey
  and l.lo_discount between 2 and 3
  and l.lo_quantity < 24
  and d.d_date='December 24, 1996';

select /*+ NO_INMEMORY */
  sum(lo_extendedprice * lo_discount) revenue
from
  LINEORDER l,
  DATE_DIM d
where
  l.lo_orderdate = d.d_datekey
  and l.lo_discount between 2 and 3
  and l.lo_quantity < 24
  and d.d_date='December 24, 1996';