Home » SQL & PL/SQL » SQL & PL/SQL » partition name based on data (oracle 11.2.0.3 sun solaris 10.5)
partition name based on data [message #597938] Wed, 09 October 2013 06:02 Go to next message
guddu_12
Messages: 227
Registered: April 2012
Location: UK
Senior Member
Dear All,

I have a range date partition table month wise which i want to truncate the partition and load for each month data i get from source.

How can i get the partion name based on data value.

e.g

source data

SALES_ID	SALES_DT

1	01/02/2008
1	01/03/2008
1	01/04/2008
1	01/05/2008



target table has same structure as source but has more data but i want to delete only those which is coming from source if it is there in target and then load. so i want to get partition name so that i can truncate and load them.
icon2.gif  Re: partition name based on data [message #597940 is a reply to message #597938] Wed, 09 October 2013 06:08 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL>  desc user_tab_partitions
 Name                             Null?    Type
 -------------------------------- -------- ----------------------
 TABLE_NAME                                VARCHAR2(30)
 COMPOSITE                                 VARCHAR2(3)
 PARTITION_NAME                            VARCHAR2(30)
 SUBPARTITION_COUNT                        NUMBER
 HIGH_VALUE                                LONG
 HIGH_VALUE_LENGTH                         NUMBER
 PARTITION_POSITION                        NUMBER
 TABLESPACE_NAME                           VARCHAR2(30)
 PCT_FREE                                  NUMBER
 PCT_USED                                  NUMBER
 INI_TRANS                                 NUMBER
 MAX_TRANS                                 NUMBER
 INITIAL_EXTENT                            NUMBER
 NEXT_EXTENT                               NUMBER
 MIN_EXTENT                                NUMBER
 MAX_EXTENT                                NUMBER
 PCT_INCREASE                              NUMBER
 FREELISTS                                 NUMBER
 FREELIST_GROUPS                           NUMBER
 LOGGING                                   VARCHAR2(7)
 COMPRESSION                               VARCHAR2(8)
 NUM_ROWS                                  NUMBER
 BLOCKS                                    NUMBER
 EMPTY_BLOCKS                              NUMBER
 AVG_SPACE                                 NUMBER
 CHAIN_CNT                                 NUMBER
 AVG_ROW_LEN                               NUMBER
 SAMPLE_SIZE                               NUMBER
 LAST_ANALYZED                             DATE
 BUFFER_POOL                               VARCHAR2(7)
 GLOBAL_STATS                              VARCHAR2(3)
 USER_STATS                                VARCHAR2(3)

[Updated on: Wed, 09 October 2013 06:09]

Report message to a moderator

Re: partition name based on data [message #597943 is a reply to message #597940] Wed, 09 October 2013 06:20 Go to previous messageGo to next message
guddu_12
Messages: 227
Registered: April 2012
Location: UK
Senior Member
but i am not able to query on high value, i want ot see my date fall in which partiton.
Re: partition name based on data [message #597944 is a reply to message #597938] Wed, 09 October 2013 06:21 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
guddu_12 wrote on Wed, 09 October 2013 16:32
I have a range date partition table month wise which i want to truncate the partition and load for each month data i get from source.

How can i get the partion name based on data value.



http://www.orafaq.com/forum/t/188219/
Re: partition name based on data [message #597947 is a reply to message #597944] Wed, 09 October 2013 06:38 Go to previous messageGo to next message
guddu_12
Messages: 227
Registered: April 2012
Location: UK
Senior Member
Many thanks
Re: partition name based on data [message #597949 is a reply to message #597938] Wed, 09 October 2013 07:05 Go to previous messageGo to next message
guddu_12
Messages: 227
Registered: April 2012
Location: UK
Senior Member
HI,

What is the syntax of truncate partition for.

alter table range_sales
truncate partition for(date '2000-02-15')

In the above example can i write month as well. where can i find the documented for the above syntax. the above example is by date wise but i want to do it month wise.
Re: partition name based on data [message #597951 is a reply to message #597949] Wed, 09 October 2013 07:27 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
guddu_12 wrote on Wed, 09 October 2013 17:35

What is the syntax of truncate partition for.

ALTER TABLE table_name TRUNCATE PARTITION FOR(partitioning_column_value);


Quote:

alter table range_sales
truncate partition for(date '2000-02-15')

In the above example can i write month as well. where can i find the documented for the above syntax. the above example is by date wise but i want to do it month wise.


If you mention a date value for that range in the partition, it will trunctae the entire partition thus selected. Why do you want to just mention the month? How are you creating the range partition? What is your requirement?
icon2.gif  Re: partition name based on data [message #597956 is a reply to message #597949] Wed, 09 October 2013 07:44 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

If you truncate the partition for a date, it truncates the whole partition and so, in your case, the whole month.

Re: partition name based on data [message #597968 is a reply to message #597956] Wed, 09 October 2013 08:25 Go to previous messageGo to next message
guddu_12
Messages: 227
Registered: April 2012
Location: UK
Senior Member
Sir, i will have 2 million records to load, that load will be followed by truncate the partition for the existing set of source data in target table. now by the above syntax i will have to take distinct of date in source and pass the value in "or(date '2000-02-15')" in truncate partition table syntax in order to truncate. my question is that the above syntax only takes date as a value or it can take something else as well
icon11.gif  Re: partition name based on data [message #597970 is a reply to message #597968] Wed, 09 October 2013 08:30 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Anything whose type matches the partition value type.
If you have partitioned by date then it must be a date.


[Updated on: Wed, 09 October 2013 08:31]

Report message to a moderator

Re: partition name based on data [message #597979 is a reply to message #597970] Wed, 09 October 2013 08:47 Go to previous messageGo to next message
guddu_12
Messages: 227
Registered: April 2012
Location: UK
Senior Member
Thanks
Re: partition name based on data [message #597992 is a reply to message #597968] Wed, 09 October 2013 11:47 Go to previous message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
guddu_12 wrote on Wed, 09 October 2013 18:55
my question is that the above syntax only takes date as a value or it can take something else as well


Guddu,
The syntax has it's own meaning. The example which I gave you, in that thread, the range partition was created on DATE. So, the PARTITION FOR clause has the same date value as an input. Understand that month is just a part of a complete date type. As explained above, whether you mention a particular date which belongs to a partition, it will truncate the entire range of that RANGE PARTITION INTERVAL.
Previous Topic: Return a list of non standard char
Next Topic: order by multiple columns
Goto Forum:
  


Current Time: Sat Apr 20 00:38:31 CDT 2024