Partitioning of existing tables.. based on date
Hello Friends,
I have some tables where their is a column called x_as_of_dt COLUMN with DATE as the datatype.
All the tables have already got data populated.
Now I want to partition the tables based on column x_as_of_dt by YYYYMM
How to approach this scenario..
Appreciate your help
thanks/kumar
Hello Justin,
I found that all the tables have indexes and check constraint only ( no primary and foreign key constraints ) for the tables that need to be partitioned .
The actual table structure is like this.. ( Am using toad and this is the script from toad )
CREATE TABLE X_FA_X_HOUSEHOLD
FINANCIAL_ADVISOR_RK NUMBER(10) NOT NULL,
HOUSEHOLD_RK NUMBER(10) NOT NULL,
X_AS_OF_DATE DATE NOT NULL,
FINANCIAL_ADVISOR_ID VARCHAR2(6 BYTE),
HOUSEHOLD_ID NUMBER(10),
X_BRANCH_ID VARCHAR2(3 BYTE),
X_FA_HHD_PCT_SPLIT NUMBER(7,4) NOT NULL,
X_RANK_NUM NUMBER(3),
PROCESSED_DTTM DATE
TABLESPACE KAW_DATA
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE UNIQUE INDEX XPKX_FINANCIAL_ADVISOR_X_HOUSE ON X_FA_X_HOUSEHOLD
(FINANCIAL_ADVISOR_RK, HOUSEHOLD_RK, X_AS_OF_DATE)
LOGGING
TABLESPACE KAW_IDX
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOPARALLEL;
GRANT SELECT ON X_FA_X_HOUSEHOLD TO KAW_READ_ROLE;
REQUIREMENT: - I got to implement the partion on this table for the column - X_AS_OF_DATE
STEP 1 - CREATE A PARTITIONed table
CREATE TABLE PARTITION_X_FA_X_HOUSEHOLD
FINANCIAL_ADVISOR_RK NUMBER(10) NOT NULL,
HOUSEHOLD_RK NUMBER(10) NOT NULL,
X_AS_OF_DATE DATE NOT NULL,
FINANCIAL_ADVISOR_ID VARCHAR2(6 BYTE),
HOUSEHOLD_ID NUMBER(10),
X_BRANCH_ID VARCHAR2(3 BYTE),
X_FA_HHD_PCT_SPLIT NUMBER(7,4) NOT NULL,
X_RANK_NUM NUMBER(3),
PROCESSED_DTTM DATE
PARTITION BY RANGE (X_AS_OF_DATE)(
PARTITION P200712 VALUES LESS THAN (TO_DATE(' 2008-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200801 VALUES LESS THAN (TO_DATE(' 2008-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200802 VALUES LESS THAN (TO_DATE(' 2008-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200803 VALUES LESS THAN (TO_DATE(' 2008-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200804 VALUES LESS THAN (TO_DATE(' 2008-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200805 VALUES LESS THAN (TO_DATE(' 2008-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200806 VALUES LESS THAN (TO_DATE(' 2008-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200807 VALUES LESS THAN (TO_DATE(' 2008-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200808 VALUES LESS THAN (TO_DATE(' 2008-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200809 VALUES LESS THAN (TO_DATE(' 2008-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200810 VALUES LESS THAN (TO_DATE(' 2008-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200811 VALUES LESS THAN (TO_DATE(' 2008-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200812 VALUES LESS THAN (TO_DATE(' 2009-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200901 VALUES LESS THAN (TO_DATE(' 2009-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200902 VALUES LESS THAN (TO_DATE(' 2009-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200903 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200904 VALUES LESS THAN (TO_DATE(' 2009-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200905 VALUES LESS THAN (TO_DATE(' 2009-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200906 VALUES LESS THAN (TO_DATE(' 2009-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200907 VALUES LESS THAN (TO_DATE(' 2009-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200908 VALUES LESS THAN (TO_DATE(' 2009-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200909 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200910 VALUES LESS THAN (TO_DATE(' 2009-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200911 VALUES LESS THAN (TO_DATE(' 2009-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P200912 VALUES LESS THAN (TO_DATE(' 2010-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201001 VALUES LESS THAN (TO_DATE(' 2010-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201002 VALUES LESS THAN (TO_DATE(' 2010-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201003 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201004 VALUES LESS THAN (TO_DATE(' 2010-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201005 VALUES LESS THAN (TO_DATE(' 2010-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201006 VALUES LESS THAN (TO_DATE(' 2010-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201007 VALUES LESS THAN (TO_DATE(' 2010-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201008 VALUES LESS THAN (TO_DATE(' 2010-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201009 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201010 VALUES LESS THAN (TO_DATE(' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201011 VALUES LESS THAN (TO_DATE(' 2010-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201012 VALUES LESS THAN (TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201101 VALUES LESS THAN (TO_DATE(' 2011-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201102 VALUES LESS THAN (TO_DATE(' 2011-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201103 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201104 VALUES LESS THAN (TO_DATE(' 2011-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201105 VALUES LESS THAN (TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201106 VALUES LESS THAN (TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201107 VALUES LESS THAN (TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201108 VALUES LESS THAN (TO_DATE(' 2011-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201109 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201110 VALUES LESS THAN (TO_DATE(' 2011-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201111 VALUES LESS THAN (TO_DATE(' 2011-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P201112 VALUES LESS THAN (TO_DATE(' 2012-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION PMAX VALUES LESS THAN (MAXVALUE) )
STEP 2 - Loading the data ---------
loading of data is as follows..
INSERT INTO PARTITION_X_FA_X_HOUSEHOLD
(FINANCIAL_ADVISOR_RK,
HOUSEHOLD_RK,
X_AS_OF_DATE,
FINANCIAL_ADVISOR_ID,
HOUSEHOLD_ID,
X_BRANCH_ID,
X_FA_HHD_PCT_SPLIT,
X_RANK_NUM,
PROCESSED_DTTM
) SELECT FINANCIAL_ADVISOR_RK,
HOUSEHOLD_RK,
X_AS_OF_DATE,
FINANCIAL_ADVISOR_ID,
HOUSEHOLD_ID,
X_BRANCH_ID,
X_FA_HHD_PCT_SPLIT,
X_RANK_NUM,
PROCESSED_DTTM
FROM X_FA_X_HOUSEHOLD
Step 3: - Creating indexes
CREATE UNIQUE INDEX XPKX_FINANCIAL_ADVISOR_X_HOUSE ON PARTITION_X_FA_X_HOUSEHOLD
(FINANCIAL_ADVISOR_RK, HOUSEHOLD_RK, X_AS_OF_DATE)
Step 4: - Droping the actual table
DROP TABLE X_FA_X_HOUSEHOLD
Step 5: Renaming the partitioned table to old tablemame
ALTER TABLE PARTITION_X_FA_X_HOUSEHOLD RENAME TO X_FA_X_HOUSEHOLD
Does the above steps are correct - pls confirm.
thanks/kumar
Similar Messages
-
Partitioning an Existing Table with data
Hi All,
I am few tables with data, I need to Partition the table without affecting existing table values is it possible?.
if yes then Please suggest me some ideas to archive that..
Thanks & Regards
SamiHi All,
I Need to partition for existing table with 1 million records
1. First partition should be created for 6 months
2.Second partition should created for 1 year.
3.So as of now we have 6 months Data in production + another 6 months data in First partition + another 1 year data in Second partition.
4.More than 2 year’s data’s should be moved other partition or archived.
kindly provide your valuabe suggestion.
Thanks & Regards
Sami -
How to create a partition on existing table?
Hey
Could some one please tell me on how to create a partition on existing table?Could some one please tell me on how to create a partition on existing table?
You can't - that isn't possible. Unless a table is already partitioned you can NOT create another partition on it.
You must either redefine the table as a partitioned table (using the DBMS_REDEFINITION package) or create a new partitioned table and move the data to its new partitions.
The choice will depend on how much data the existing table has and whether you can do it offline. -
What's the best practice to partition an existing table?
We are using Oracle 11g EE 11.2.0.3.0. We want to partition an existing table. I found some information from this link [http://www.oracle-base.com/articles/misc/partitioning-an-existing-table.php], but I am not sure whether that's the best way. Could anyone share the best practice of partitioning an existing table?
Thanks.
Jun>
We want to partition a few related tables. A couple of tables have about 30 million rows, and a couple of other tables have about 10 million rows. The data for those tables is for ~2000 accounts, each of them is identified by a column named "account_id". We want to partition the tables by using the "account_id" as the partition key to gain better performance for queries, so we would probably use hash partition. Please advise.
>
1. What evidence do you have that your performance will be any better if you partition those tables?
2. What evidence do you have that there is anything wrong with the performance of your current queries?
3. Have you reviewed the actual execution plans for your most important queries to see if there is even any room for improvement?
If your query uses account_id as a predicate but only pulls a few records from a 'master' table for that key value your performance may actually be worse if you partition that table. That is because using an index range scan Oracle can easily find the ROWIDs of the rows that need to be selected and then easily retrieve them regardless of their physical location.
If you have queries that do NOT use account_id but currently use indexes the performance of those queries may also be worse if you partition that table. Those indexes will be GLOBAL.
There are two major implications when you use hash partitioning:
1. Any query that does NOT include the partitioning key (account_id for your case) will, of necessity, have to use a full table scan if an appropriate index is not available.
2. You will get NO management benefits such as being able to add/remove partitions that include old data.
Before you decide to partition a table you should conduct tests and examine the execution plans for your important queries. -
How can I partition an existing table? What's the SQL syntax?
Thanks for help,
Chen ZhaoDoes anybody know how to partition an existing table?
YES! That is the simple answer to your question. There are a lot of people that know how to do that.
Whether partitioning is appropriate and, if so, which method might be 'best' for YOU depends on the particulars of your use case. But as with most problems you need to make sure you troubleshoot whatever issue you have in the proper order:
1. Identify a PROBLEM or issue that needs to be resolved - you haven't told us anything. Please post info about this
2. Validate that the problem/issue actually exists (it could just be a fluke occurence)
3. Identify potential solutions to the problem/issue - that list of solutions may, or may not, include partitioning
4. Select a small number (e.g. 1 or 2) of those solutions for further analysis and actual tests.
5. Select the 'best' (based on your orgs criteria) of those tested solutions for implemention
You seem to already be on step #5. But in order for us to help you we have to understand what the results of steps 1 thru 4 are.
Please post the information about your PROBLEM that we need to help you. -
Partitioning an Existing Table
Dear Forum,
Can we create partition on an existing table without dropping it in Oracle 11.2.0.3.0?
I know EXCHANGE PARTITION, but that I don't want.
Thank you & regards.You cannot partition an existing table.
You have to create a new partitioned table and move the data from the old table to the new table. If you want to do this online, you can potentially leverage the DBMS_REDEFINITION package to help you out. Behind the scenes, you're still creating a new table and, eventually, dropping the old table after moving all the data over. DBMS_REDEFINITION hides some of that from you and lets the table remain online while you are moving the data. But it adds some performance overhead.
Justin -
How to fill setup table based on date???
Hi Experts,
I need to do repair full request for 2lis_11_vaitm datasource, I want to load from 1st Apr 2008 to 31st March 2009, but in OLI7BW t-code i am unable to find date field in selection screen.
1) How can I fill setup table based on date?
2) In RSA7 containing records even though is it possible to fill setup table ?
Helpful answer will be appreciated with points,
Thanks in advance,
Venakt.Venkata,
1) How can I fill setup table based on date?
--> If date not possible then try to setup with available options/characteristics.
--> While pulling into BW, extract data selectively. Give date selection at infopcakge.
2) In RSA7 containing records even though is it possible to fill setup table ?
--> Yes, you can do it.
Srini -
Create partition to existing table
I have a existing table which is not partitioned. How can partition my existing table?
oops.... This is more better....
Partitioning an Existing Table
http://www.oracle-base.com/articles/misc/PartitioningAnExistingTable.php
Other method
(1) create new_table with oen or more range partition.
(2) alter table new_table exchange partition with old_table.
(3) rename or drop old_table.
(4) rename new_table to old_table.
(5) split or add partition.
-- Examples
--(1)
create table part_tab
partition by range (col)
(partition p1 values less than (maxvalue))
as select * from org_tab where 1=0;
--(2)
alter table part_tab
exchange partition p1 with table org_tab
without validation
--(3)
rename org_tab to backup_table;
--(4)
rename part_tab to org_tab;
--(5)
alter table org_tab
split partition p1 at (100)
into (partition p1, partition p2);
alter table org_tab
split partition p2 at (200)
into (partition p2, partition p3);
-- Results
SQL> select * from org_tab partition(p1);
COL VC
99 abc
SQL> c/p1/p2
1* select * from org_tab partition(p2)
SQL> /
COL VC
199 def
Original is written in Japanese language (OTN Japan)
http://otn.oracle.co.jp/forum/message.jspa?messageID=3045618?
Message was edited by:
ushitaki -
Creating Partitions in Existing tables with Data
Hello everyone,
I want to know what the best way of creating partitions, in tables having data, is .. ???
thanks
Rossy RocsThere are two ways :
1a Create a new Partitioned Table
1b Copy data from the existing table to the new table
1c Create Indexes
1d Rename old table
1e Rename new table
OR
2 Use DBMS_REDEFINITION
See
http://www.oracle-base.com/articles/misc/PartitioningAnExistingTable.php
Hemant K Chitale -
Suggestions for table partition for existing tables.
I have a table as below. This table contains huge data. This table has so many child tables .I am planning to do a 'Reference Partitioning' for the same.
create table PROMOTION_DTL
PROMO_ID NUMBER(10) not null,
EVENT VARCHAR2(6),
PROMO_START_DATE TIMESTAMP(6),
PROMO_END_DATE TIMESTAMP(6),
PROMO_COST_START_DATE TIMESTAMP(6),
EVENT_CUT_OFF_DATE TIMESTAMP(6),
REMARKS VARCHAR2(75),
CREATE_BY VARCHAR2(50),
CREATE_DATE TIMESTAMP(6),
UPDATE_BY VARCHAR2(50),
UPDATE_DATE TIMESTAMP(6)
alter table PROMOTION_DTL
add constraint PROMOTION_DTL_PK primary key (PROMO_ID);
alter table PROMOTION_DTL
add constraint PROMO_EVENT_FK foreign key (EVENT)
references SP_PROMO_EVENT_MST (EVENT);
-- Create/Recreate indexes
create index PROMOTION_IDX1 on PROMOTION_DTL (PROMO_ID, EVENT)
create unique index PROMOTION_PK on PROMOTION_DTL (PROMO_ID)
-- Grant/Revoke object privileges
grant select, insert, update, delete on PROMOTION_DTL to SCHEMA_RW_ROLE;I would like to partition this table .Most of the queries contains the following conditions.
promo_end_date >= SYSDATE
and
(event = :input_event OR
(:input_Start_Date <= promo_end_date
AND promo_start_date <= :input_End_Date))Any time the promotion can be closed by updating the PROMO_END_DATE.
Interval partioning on PROMO_END_DATE is not possible as PROMO_END_DATE is a nullable and updatable field.
I am now to table partition.
Any suggestions are welcome...DO NOT POST THE SAME QUESTION IN MULTIPLE FORUMS PLEASE!
Suggestions for table partition of existing tables -
Need to fetch value from a table based on data range
Hello there,
I was hoping that the community could give me a hand with this little puzzle I got.
I am currently creating a Time Dimension for a data wharehouse, and I have the requirement to populate a column named SEASON (e.g: Summer, Winter, Spring, Autumn) for each date row. So for the 20/Dec/2013, the Season column must say Winter.
Here is now my Time Dimension table looks like, without the Season information (which I yet have to load):
DimTime Table
TIMEID
FULLDATE
YEAR
SEASON
MONTH
MONTHDAY
WEEK
WEEKDAY
274
02-MAR-10
2010
3
2
9
2
275
03-MAR-10
2010
3
3
9
3
276
04-MAR-10
2010
3
4
9
4
277
05-MAR-10
2010
3
5
9
5
278
06-MAR-10
2010
3
6
9
6
279
07-MAR-10
2010
3
7
9
7
This entire table is being populated using Oracle functions to manipulate a date field from another table, named PDATE:
My ETL Code
INSERT INTO DimTime(timeid, fulldate, year, month, monthday, week, weekday)
SELECT tim_seq.NEXTVAL, pdate, year, month, monthday, week, weekday
FROM (SELECT DISTINCT pdate, EXTRACT(year from pdate) year, EXTRACT(month from pdate) month,
EXTRACT(day FROM pdate) monthday, to_number(to_char(to_date(pdate,'DD/MM/YY'),'IW')) week,
TO_CHAR(pdate, 'D') weekday
FROM Performance PER
ORDER BY pdate);
NOTE: Code considers the table DimTime to be truncated every time it loads (i.e.: I don't need to consider additional loads).
As you can see, Season wasn't populated. Since the solstices and equinoxes vary for each year, I can't just say that Summer start at a given date (e.g: 21 of June) because one year it could be the 19/Jun, another the 22/Jun, etc. So in order to solve this problem, I have a table named Season which defines the START and END dates for the seasons:
Season Table
SEASON#
SEASONNAME
YEAR
DATEFROM
DATETO
1
Spring
2010
01-MAR-10
30-MAY-10
2
Summer
2010
31-MAY-10
29-AUG-10
3
Autumn
2010
30-AUG-10
28-NOV-10
4
Winter
2010
29-NOV-10
27-FEB-11
5
Spring
2011
28-FEB-11
29-MAY-11
6
Summer
2011
30-MAY-11
28-AUG-11
7
Autumn
2011
29-AUG-11
27-NOV-11
8
Winter
2011
28-NOV-11
26-FEB-12
9
Winter
2009
30-NOV-09
28-FEB-10
This is the bit I don't know how to do. How can I make sure that I populate the correct Season in my DimTime table based on the season specified in the Season table?
Thanks in advance for your help!
Regards,
P.Just join to table Season:
INSERT
INTO DimTime(
timeid,
fulldate,
year,
month,
monthday,
week,
weekday,
seasonname
SELECT tim_seq.NEXTVAL,
pdate,
year,
month,
monthday,
week,
weekday
FROM (
SELECT DISTINCT pdate,
EXTRACT(year from pdate) year,
EXTRACT(month from pdate) month,
EXTRACT(day FROM pdate) monthday,
to_number(to_char(to_date(pdate,'DD/MM/YY'),'IW')) week,
TO_CHAR(pdate,'D') weekday,
seasonname
FROM Performance PER,
season
WHERE pdate between datefrom and dateto
SY. -
To select from database table based on date range
hi
i have a selection screen in which date range is being given
say eg 23/06/07 to 23/12/08
based on this date i want to select data from a ztable
eg i want to select a field amount from table
and three is a field date range on the table
for this particular field i want to select all records for amount field and factual field falling wiithing this date range and sum it
eg
based on date range as in selcetion screen
select amount( field1) factual ( field2) from ztable into it_ztable where date = ?....
please give me code for it and how to sum all values as i will get from the ztable into internal table the two values as fetched from the ztable
please suggest asap
regards
arorahi
i am using
sELECT field1 field2 FROM Ztable INto it_matu
where DATE GE sl_dat-low
AND DATE LE sl_dat-high.
i am getting data in internal table but
say i have twelve records now i want to sum it the both the columns into and use that sum final amount to display
let me know how to use sume in the intrranal tabl do i need to use control statement
how to use the sum for two columns and take into a serperate variable to display
regards
aRora -
Table partitioning (intervel partitioning) on existing tables in oracle 11g
Hi i'm newbie to table partitioning. I'm using 11g. I have table of size 32 gb (which has 22 million records) and i want to apply interval partition on that table. I created a empty table with a partition having columns same as source table and take dump of the source table and import into the new partition table. can you please suggest how to import table dump into new table? also is there any other better idea to do the same.
Hi,
imp user/password file=exp.dmp ignore=y
The ignore=y causes the import to skip the table creation and continues to load all rows.
On the other hand, you can insert data into the partitioned table with a subquery from the non-partitioned table such as follows;
insert into patitioned_table
select * from original_table;
Hope it helps, -
Updating tables based on Dates
In my application I use some tables with a date field.
table: employee
period date (e.g. 01-01-2004, 01-02-204, 01-03-2004)
target money
result money
table: project
date date (e.g. 15-01-2004, 20-01-2004, 03-02-2004)
revenue money
If I book a new project the table employee should be updated with result = result + revenue. If there is a new project on 15-01-2004 the record in employee where period = 01-01-2004 should be updated.
Can someone help me with a sample code for this problem?Assuming you have a block in the form call PROJ with fields DATE, REVENUE and EMP_NO. Also that a record exists for the employee and period date.
Create PRE-INSERT and PRE-UPDATE triggers on the block PROJ containing
begin
update employee
set result=result+:PROJ.REVENUE
where period_date=trunc(:PROJ.DATE,'Mon')
and emp_no=:PROJ.EMP_NO;
end -
Partition an Existing Table with Data
We have a table that is approx. 23Gb with 90 million rows. We need to partition it. What is the fastest or most efficient way to accomplish this? Oracle 10.2.0.4.
user1175547 wrote:
We have a table that is approx. 23Gb with 90 million rows. We need to partition it. What is the fastest or most efficient way to accomplish this? Oracle 10.2.0.4.you can use DBMS_REDEFINITION, also exchange partition is also a good solution :)
http://www.oracle-base.com/articles/misc/PartitioningAnExistingTableUsingExchangePartition.php
Maybe you are looking for
-
Reinstalled Itunes for Windows will not recognize ipod touch 3rd generation.
Itunes for Windows and PC will not recognize my ipod touch 3rd generation. Also it will not fully charge using a brand new apple brand power adapter and cable. I have already uninstalled all Apple software on PC and reinstalled. I've tried every st
-
How do I save documents from iCloud into pages on my ipad?
HOw do I save documents from iCloud into pages using an ipad?
-
I've created a simulation in Flash 8. The simulation is working fine in IE7 but when I'm launching the sim in Safari browser the sim is not working as it should. I'm getting some issues like: Some SWFs are not getting loaded. Some Functions are not w
-
I want to use the DATASOURCE 0SEM_BCS_10
Hi All, I want to use the DATASOURCE 0SEM_BCS_10. I activated the datasource in R/3 SAP ECC 6.0, but when in tried to to check the extrtactionin Transaction RSA3, I go no records for this datasource. Is there any other setttings to be done before w
-
I experience strange vertical lines over the text
I experience strange vertical lines over the text. i belive it started when i updated my firefox to it's latest version i tried synchronizing me clear view, but it didn't help