Computer >> Computer tutorials >  >> Programming >> Database

Oracle 19c New Feature : Hybrid Partitioning

In Oracle 12c Release 2 version, Oracle introduced a feature which provided us ability to create partitions on External Tables. In the Oracle 19c version, Oracle introduced a new feature called Hybrid Partitioning which allows us to create some partitions external to database i.e. flat files and some partitions in the tablespace i.e internal to database.

With the help of this feature, we can move less used old partitions to external source i.e. Linux file system and most active partitions in the database. In this demo, we will create a Hybrid Partitioned Table called DATA with 4 partitions DATA_2019, DATA_2020, DATA_2021 & DATA_2022. Data for year 2019, 2020 & 2021 are stored in flat files in OS directory /home/oracle/data_dir.

These 3 flat files contains data for year 2019, 2020 and 2022 separated by whitespace.

Step 1: Login to database and set the target PDB in which table needs to be created.

Step 2: Create a directory DATA_FILES_DIR in the database pointing to OS directory data_dir. Create user APP_USER and give READ, WRITE permissions on directory.

Step 3: Create Hybrid Partitioned table DATA in APP_USER. Partitions DATA_2019, DATA_2020 & DATA_2021 are external to database and contains data in flat files. But partition DATA_2022 is internal to database.

Step 4: We are able to run query data from each partition.

DATA_2019 -

DATA_2020 -

DATA_2021 -

DATA_2022 -

Step 5: Check if the created table DATA is Hybrid partitioned table?

Step 6: When trying to insert data in partition DATA_2022, it fails with error ORA-01950: no privileges on tablespace ‘USERS’. This confirms that data in partition DATA_2022 will be stored in USERS tablespace i.e. internal to database. When giving quota on tablespace USERS, we are able to insert data in partition DATA_2022.

Step 7: Below query shows that only partition DATA_2022 is stored in the database. Other partitions data is external to database.

Conclusion

Using this new feature we can move older partitions of a table which are not active to some other cheaper storage outside the database – whereas the active table data remains inside the Oracle database.

Use the Feedback tab to make any comments or ask questions. You can also start a conversation with us.