Swaminathan K
asked on
Oracle partition by range
Hi Team ,
I need to create a table partition which can store the employees who have joined in a given month and year
Can I achieve it using range partition
Iam trying the below command.
Create table emp_part1
(
employee_id number,
hire_date date
)
PARTITION BY RANGE(hire_date)
(
PARTITION pos_data_p2 VALUES LESS THAN (TO_date(HIRE_DATE', 'MM-YYYY')),
PARTITION pos_data_p3 VALUES LESS THAN (TO_DATE(HIRE_DATE, 'MM-YYYY'))
);
Actually i want to create partitions like below
MONTH-YEAR
JAN-2007
FEB-2007
create partitions like above and store the records , but iam getting an error
I need to create a table partition which can store the employees who have joined in a given month and year
Can I achieve it using range partition
Iam trying the below command.
Create table emp_part1
(
employee_id number,
hire_date date
)
PARTITION BY RANGE(hire_date)
(
PARTITION pos_data_p2 VALUES LESS THAN (TO_date(HIRE_DATE', 'MM-YYYY')),
PARTITION pos_data_p3 VALUES LESS THAN (TO_DATE(HIRE_DATE, 'MM-YYYY'))
);
Actually i want to create partitions like below
MONTH-YEAR
JAN-2007
FEB-2007
create partitions like above and store the records , but iam getting an error
how many billions of records do you have in this table?
i suggest, just create a function index
create index ix_hiredate
and you should be ok, just use same function when querying your data to be able to use the index...
i suggest, just create a function index
create index ix_hiredate
CREATE INDEX ix_hiredate ON emp (to_char(hire_date, 'YYYYMM'));
and you should be ok, just use same function when querying your data to be able to use the index...
you typically wouldn't setup partitioning for an employees table
there is only 7.5 billion people, and i'm sure not all of them work at your company
especially the kids and elderly/retired people
you might want to setup partitioning on the daily activity of all those employees
but that's not gonna be all that much either
you have chosen a very odd case for partitioning ...
unless this is for learning ?
there is only 7.5 billion people, and i'm sure not all of them work at your company
especially the kids and elderly/retired people
you might want to setup partitioning on the daily activity of all those employees
but that's not gonna be all that much either
you have chosen a very odd case for partitioning ...
unless this is for learning ?
What is the data type of your hiredate field?
>>What is the data type of your hiredate field?
pssssttttt...... The create table statement was provided? ;)
pssssttttt...... The create table statement was provided? ;)
ASKER
its date field. Sorry for the late reply
ASKER
here iam just providing the sample table as employees, on real scenario its a different table sales_order table. kindly consider employees table and do the needful.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>You might find it convenient to make your partition names a little more meaningful
For most all other partitioning types, I agree. Interval partitioning will automatically create new partitions as the data dictates. You have to remember to pre-create ALL possible partitions or rename them after the system generates them.
For most all other partitioning types, I agree. Interval partitioning will automatically create new partitions as the data dictates. You have to remember to pre-create ALL possible partitions or rename them after the system generates them.
ASKER
thanks a lot. u guys are awesome
See REF on partitioning tables https://docs.oracle.com/cd/B28359_01/server.111/b32024/partition.htm
Your partitioning directive should actually set the range explicitly that the partition will contain, you do not seem to set the date
pos_data_p2 is less than 'JAN-2007' instead of the column name in your example HIRE_DATE
You might want to create a loop, that will go through years, months, to create the partitions on a monthly basis.
you also seem to have an extra quote in the first HIRE_DATE...
Without knowing the data, it is not clear to be the benefit you will see since it is unlikely that you have huge tables of people churn hired/leave/terminated