Oracle 12c introduces a way to compress tables on the fly, during import using impdp.
Use the directive
transform=table_compression_clause:"row store compress advanced"in your impdp parameter file.
Documentation here
Minimalistic Oracle contains a collection of practical examples from my encounters with Oracle technologies. When relevant, I also write about other technologies, like Linux or PostgreSQL. Many of the posts starts with "how to" since they derive directly from my own personal experience. My goal is to provide simple examples, so that they can be easily adapted to other situations.
transform=table_compression_clause:"row store compress advanced"in your impdp parameter file.
select now()+'90 days' as expiry; expiry ------------------------------- 2019-08-07 10:07:01.172082+02 \gset alter user jim valid until :'expiry'; ALTER ROLE
mydb01=# \du List of roles Role name | Attributes | Member of -------------------+------------------------------------------------------------+--------------------- postgres | Superuser, Create role, Create DB, Replication, Bypass RLS+| {} | Password valid until 2019-01-16 00:00:00+01 | superuser | Superuser +| {} | Password valid until 2019-08-04 00:00:00+02 | jim | Password valid until 2019-08-07 10:07:03.237862+02 | {}
mydb01=# \list List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+------------+------------+------------------------------ postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 | template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres + | | | | | postgres=CTc/postgres mydb01 | jim | UTF8 | en_US.utf8 | en_US.utf8 | =Tc/jim + | | | | | jim=CTc/jim +
alter role jim password 'mynewpassword';
SET enable_partition_pruning to on;
explain select * from documents where dokumenttype='SUBPOENA'; QUERY PLAN --------------------------------------------------------------------- Append (cost=0.00..1.02 rows=1 width=774) -> Seq Scan on P_SUBPOENA (cost=0.00..1.01 rows=1 width=774) Filter: ((documenttype)::text = 'SUBPOENA'::text) (3 rows)Since this is the LIST-partitioned table outlined in this post, I know the optimizer picked the correct partition for my predicate.
explain select * from orders where country_code='se' and order_total between 4000 and 4999; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------- Append (cost=0.00..28.21 rows=1 width=50) -> Seq Scan on large_orders_se (cost=0.00..28.20 rows=1 width=50) Filter: ((order_total >= '4000'::numeric) AND (order_total <= '4999'::numeric) AND ((country_code)::text = 'se'::text)) (3 rows)
"Subquery Scan on andre (cost=1000.00..10024950.78 rows=294885 width=84)" " -> Gather (cost=1000.00..10013892.60 rows=294885 width=64)" " Workers Planned: 2" " -> ProjectSet (cost=0.00..9983404.10 rows=29488500 width=64)" " -> ProjectSet (cost=0.00..9830063.90 rows=12286900 width=128)"
CREATE TABLE DOCUMENTS( DOC_ID INTEGER NOT NULL, LEGAL_ENTITY INTEGER NULL, CREATED_DT DATE NOT NULL, REGION VARCHAR(30) NULL, DOCUMENTTYPE VARCHAR(100) NULL, DOCUMENTNAME VARCHAR(1000) NULL ) PARTITION BY LIST (DOCUMENTTYPE);
CREATE TABLE P_SUBPOENAS PARTITION OF DOCUMENTS FOR VALUES IN ('SUBPOENA'); CREATE TABLE P_AFFIDAVITS PARTITION OF DOCUMENTS FOR VALUES IN ('AFFIDAVIT'); CREATE TABLE P_MEMORANDOMS PARTITION OF DOCUMENTS FOR VALUES IN ('MEMORANDOM'); CREATE TABLE P_DEFAULT PARTITION OF DOCUMENTS DEFAULT;
SELECT * FROM DBA_AUDIT_MGMT_LAST_ARCH_TS;
BEGIN DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP ( AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED, LAST_ARCHIVE_TIME => SYSTIMESTAMP-30); END; /
BEGIN DBMS_AUDIT_MGMT.clean_audit_trail( audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED, use_last_arch_timestamp => TRUE); END; /
BEGIN DBMS_AUDIT_MGMT.clean_audit_trail( audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED, use_last_arch_timestamp => FALSE); ); END; /
CREATE UNIQUE INDEX MYTABLE_IDX1 ON MYTABLE (ID,CATEGORY) LOCAL TABLESPACE USERS ONLINE;
ALTER TABLE MYTABLE ADD ( CONSTRAINT UK_MYTABLE UNIQUE (ID,CATEGORY) USING INDEX MYTABLE_IDX1 );
ALTER TABLE MYTABLE ADD ( CONSTRAINT MYTABLE_PK PRIMARY KEY (ID) USING INDEX);