Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Script / Table Partitioning

Is there an easy way to determine in a SQL Script if the ORACLE Table Partitioning feature is available?

I want to create some of my tables as partitoned tables if the feature is available, otherwise the tables should be created normally. I have a script with my DDL which I use to setup the database via sqlplus.

Thanks.

JeHo

like image 460
Jeldrik Avatar asked Nov 18 '25 19:11

Jeldrik


2 Answers

The following query will tell you whether partitioning is enabled:

select value from v$option where parameter = 'Partitioning';

If partitioning is not available then you should get this error:

ORA-00439: feature not enabled: Partitioning

So you could write PL/SQL in your script to create the table like this:

declare
  no_partioning exception;
  pragma exception_init (no_partioning, -439);
begin
  execute immediate 'CREATE TABLE mytable ...'; -- with partioning clauses
exception
  when no_partioning then
    execute immediate 'CREATE TABLE mytable ...'; -- without partioning clauses
end;
/
like image 45
Tony Andrews Avatar answered Nov 20 '25 07:11

Tony Andrews



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!