Hi,
Another way is to get the partition name for a value. Here are some solutions:
http://oraclesponge.blogsp
Regards,
Franck.
Main Topics
Browse All TopicsCan anyone advise, on how can i retreive specific partition name for a table 'test 'based on high value column of user_tab_partitions table as High_value column has value-'TO_DATE(' 2009-10-09 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')'
The sql query am trying to use -
select * from USER_TAB_PARTITIONS
where TABLE_NAME like 'test' and high_value =???
I want to retrive partition name from Table test which belong to hiredate='2/10/2009' where hire date is a partition key in a table on base of which partition is created.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi,
Another way is to get the partition name for a value. Here are some solutions:
http://oraclesponge.blogsp
Regards,
Franck.
to find the partition that has data of a certain value you will need to look > your date
and then pick the lowest one
something like this...
SELECT *
FROM (SELECT p.*, get_partition_date(USER, table_name, partition_name) part_date
FROM user_tab_partitions p
WHERE table_name = 'TEST'
AND get_partition_date(USER, table_name, partition_name) >
TO_DATE('2000-11-03', 'yyyy-mm-dd')
ORDER BY part_date)
WHERE ROWNUM = 1
Hi Stuber,
below is the issue , am getting while trying to retreive partition name. I want to retreive partition name base on actual date and not max value as in Rane partition, i can see the High value set does not represent the actual date it contains data.
If i am querying for 11/02/2009 , i want to retreive partition name emp_20091103 which actually contains that dta. Please advise-
Can anyone advise me on following scenario-
I have a table which is partition by range on Create_Date Column.
I add partition in following way-
ALTER TABLE Emp ADD PARTITION Emp_20091102 VALUES LESS THAN ( to_date('11/03/2009'',''MM
I created procedure to retreive partition name base on high value.
As high_value column in user_tab_partitions have '11/03/2009' as high value for partition Emp_20091102,though it contain data less than 11/03/2009. but i want to retreive partition name base on "less than max value criteria"
When i try to execute following query,
SELECT partition_name
FROM user_tab_partitions
WHERE table_name = Emp
AND get_partition_date(USER, table_name, partition_name)=TO_DATE('1
Below is the procedure, i have used to retreive partition name-
CREATE OR REPLACE FUNCTION Hina_get_partition_date(p_
p_table IN VARCHAR2,
p_partition IN VARCHAR2)
RETURN DATE
IS
v_str VARCHAR2(32767);
v_date DATE;
BEGIN
SELECT high_value
INTO v_str
FROM dba_tab_partitions
WHERE table_owner = p_owner AND table_name = p_table AND partition_name = p_partition;
IF UPPER(v_str) = 'MAXVALUE'
THEN
v_date := TO_DATE('9999-12-31 23:59:59', 'yyyy-mm-dd hh24:mi:ss');
ELSE
EXECUTE IMMEDIATE 'select ' || v_str || ' from dual' INTO v_date;
END IF;
RETURN v_date;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line(v_str
RETURN NULL;
END;
Also,
Stuber,
If i want to put a specific date data into one specific partition--
say p1_20090103 will have data for 20090102 only,
p1_20090104 will have data for 20090103 only.
for which am creating daily partitions base on sysdate..
For this only range partitioning will work and not List partitioning. Please advise if am wrong.
you "could" use list partitioning, but you'd have to list every possible date value you wanted in your partitions. Since one day has 86400 seconds that could each be distinct date type, it's not really feasible, or legal to list all of them.
if your data was just for a single day (time=00:00:00) or hour (minutes/seconds=00:00) then it might be possible but still not particularly useful.
I'd use range partitioning, plus, in 11g your range partitions can be generated automatically for you based on a daily interval
Hi,
I'm not sure to understand why you need the partition name.
But as you say that you want it for actual data (then I hunderstand for rows that re already in table), you should consider to use pmarker:
- you get the rowid for the firstrow that fits your date
- you query dba_objects where data_object_id = dbms_mview.pmarker( <the rowid you get> )
and you have partition name
This is very fast (because the rowid has the partition information insite it - as the data object id)
Regards,
Franck.
suniblains, you might have missed the post above http:#25744122 answers the question you asked in http:#25744126 a minute afterward
Business Accounts
Answer for Membership
by: sdstuberPosted on 2009-11-03 at 13:31:40ID: 25733986
you'll have to create a function that will read the long column and turn it into a date for you
try something like this...
SELECT *
FROM user_tab_partitions
WHERE table_name = 'TEST'
AND get_partition_date(USER, table_name, partition_name) = TO_DATE('2000-01-01', 'yyyy-mm-dd')
Select allOpen in new window