transfer data to another table
I'm using Oracle 10.2.04. I have a table table1 that has about half a million records. At the end of the year 90% of these files are only needed for purposes of archiving during 1 year.We are planing to create archive table table2 to say is similar to table1 so that we can insert data redundant from table1 to table2 and delete the records from table1. In this way table1 is be much smaller and faster to work with.
I want to know experts in the forums, what they think of our approach and insert and delete. Is there a better way to do it. I was consider adding a flag column, maybe partitioning etc. I would like to know what you think. All the tips and suggestions is greatly appreciated.
I'll get exactly the records that would be redundant. I only meant those recordset is 90% of the total number of records.
If you say so.
unique post SQL SELECT that produces the result set of records to be (re) moved.
Tags: Database
Similar Questions
-
How can I insert data from another table into a table containing a timestamp column
How you insert data from another table in a table if the target table contains a timestamp column. I tried to set the default value of GETDATE() column in the target table, but it does not work.
I use MS SQLSorry, I managed to get around this by inserting null as the value
-
Redirect data to another table using before insert trigger.
Dear all,
How can I redirect the data to another table in a before Insert trigger? My database is Oracle10g.
I have a table EMP (EMP_ID, LAST_NAME, SALARY).
I have another EMP_COPY table with the same structure. I also have a before Insert trigger on the EMP table.
Based on a condition that I have to redirect the data in table EMP_COPY. Let's say the condition is EMP_ID = 100.
I fire an insert on EMP table for example INSERT IN EMP(EMP_ID,LAST_NAME,SALARY) VALUES(100,'Dev',500).
On the inside of the front Insert trigger on the EMP table, I have the code
IF EMP_ID = 100 THEN
INSERT INTO EMP_COPY (EMP_ID, LAST_NAME, SALARY)
VALUES(:NEW.) EMP_ID,: NEW. LAST_NAME,: NEW. SALARY);
COMMIT;
ON THE OTHER
NULL;
END IF;
But the problem here is that data goes to EMP table of origin also although I don't want. He should do an Insert into EMP table only if EMP_ID! = 100.
One way has been to raise a user-defined exception inside the If statement and not handle it so that the original insert on table EMP fails but INSERT comes in the EMP_COPY table. But in this solution since the inside the trigger unhandled exception, it propagates to the calling environment. And I can't stand outside relaxation as the calling environment is a form of Oracle Apps standard that cannot be customized.
Any kind of help will be highly appreciated that I am fighting for more than two weeks.
Thanks in advance
DevRemove the autonomous transaction pragma... and then try again.
-
Select table data in another table
Hello
I want to select data from A table, which is not in table B.
Currently I am doing:
Select
smofnut,
nameA,
dobA
a.
If smofnut not in
(select A snoB, B).
where smofnut = snoB
and nameA = Name)
But above all it is very slow.
I can do something like:
Select
smofnut,
nameA,
dobA
of A, B
where
EXCLUDE (smofnut = snoB and nameA = Name)
Please note that I need the place where the condition on the two columns.
any help will be appreciated.
-HarveyWhat are approximate data to A and B?
What is 'very slow '?
What version of Oracle?
What is the query plan?Without knowing anything about your system, my first thought would be to see if a NOT EXISTS happened to be faster for your data
SELECT snoA, nameA, dobA FROM a WHERE NOT EXISTS ( SELECT 1 FROM b WHERE a.snoA = b.snoB AND a.nameA = b.nameB )
Of course, I don't know why you want to join A & B in your NOT IN subquery. It would seem that you would need just a subquery correlated, i.e.
SELECT snoA, nameA, dobA FROM a WHERE snoA NOT IN ( SELECT snoB FROM b WHERE a.snoA = b.snoB AND a.nameA = b.nameB )
This should be more efficient than the original request. The NOT EXISTS version may or may not be more effective than NOT IN according to data volumes.
Justin
-
update of data from another table
Hi, I would like to help. I Don t know how I can start doing:
I have a table with a column with numbers (primary key) and I need to create another column with the same values,
I want to change a table that has only numeric values (PK) to another
value, so I disable the constraints of linked tables
then I create another column that I called the "d" column and copy the values
from column A to column D
For example.
TABLE XYZ
COLUMN A: COLUMN D: (NEW)
00001 00001
00002-00002
00003-00003
00004 00004
Can I change the values in column A and D of the column will be kept
TABLE XYZ
COLUMN A: COLUMN D:
00001 99901
99902 00002
99903 00003
99904-00004
As the tables that must "point" to the column, I change the values with the new numbering
TABLE ZZZZ
COLUMN B: (the values of the column before the change)
00001
00002
00003
00004
...
I want it like this:
99901
99902
99903
99903
99904
...
In other words, I find the current value in column D of the XYZ table for the new value that is in column a.
I appreciate the help! :)Try this
Here you will find a record in test1 for a record for each line of teste2 in teste2 joined the condition t1.numer_documento2 = t2.numero_documento.This is called as subquery related Co. What you were doing was under queries that and not to join the top request.
UPDATE teste2 t2 SET NUMERO_DOCUMENTO = (SELECT T1.NUMERO_DOCUMENTO FROM teste1 t1 WHERE t1.numer_documento2 = t2.numero_documento and ROWNUM = 1 ) -- "Check/Select your data before you commit "
SS
-
Save the data in another table
Hello, I would like someone to help me with a problem I have in my program.
What makes the program is, for each iteration, take the data in 'table iter' and recorded in "table of output." But in the second iteration instead of storing the results of the first iteration offer me '1' in the first five lines.How can I solve this problem?
Thank you, Jaime
Hi pescajaime,
Please make the change mentioned in the attachments.
Thank you and best regards,
srikrishnaNF
-
SkyDrive allows you to transfer data to another computer
Hi all: I bought another computer. Can I use skydrive to transfer all the files from the old computer to the new? I ordered a transfer cable, but I was wondering if I need now. Thank you. Bob L.
Bob
It would be 10 to 100 times faster than cable. No idea what your connection speed is only a load more than 5 MB is unusual during the transfer cable can be ~ 500 Mb
-
read in select data from another table
Hello world.
IM Oracle11GR2 database.
I m facing the following problem:
I have 2 tables.
In the first picture, I have a few articles and 3 of these items then come.
(A) point Varchar2
(B) Item Varchar2.
(C) point digital and this point is the id of a record in the other table.
If the digital point > 0 then points A and B must be read in the second table
In the second table, I have 3 Articles.
(A) the id of the record.
B & C point are also point varchar2 and must be read in the first table, point C is > 0.
I'm looking for the way that when I write a normal selection in the first picture he gives me the point B & C of the second table if C point in the first table is > 0.
I thought to solve this problem with a trigger or something similar.
Any idea is welcome.
Regards to everyone.
You don't need a trigger for this. A simple select statement should do. Something like that? I got your if condition perfectly.
SELECT CASE WHEN (T1. C > 0) THEN (SELECT T2. B OF THE T2 WHERE T1. C = T2. (A) T1 OTHERWISE. END A,
BOX WHEN (T1. C > 0) THEN (SELECT T2. C FROM T2 WHERE T1. C = T2. (A) T1 OTHERWISE. B END HAVE B,
T1. C
FROM T1;
Look at the following example. Check if it fills your scenario.
-BEGINNING OF THE SAMPLE DATA
WITH T1 AS)
SELECT 'A' A, 'B' B, 1 C OF DOUBLE UNION ALL
SELECT 'C', ', 2 DOUBLE UNION ALL
SELECT 'DF', 'G', THE DOUBLE 0),
() AS T2
SELECT 1, 'X' B 'Y' C DOUBLE UNION ALL
SELECT 2, 'Z', 'BB' OF THE DOUBLE)
-END OF THE SAMPLE DATA
SELECT CASE WHEN (T1. C > 0) THEN (SELECT T2. B OF THE T2 WHERE T1. C = T2. (A) T1 OTHERWISE. END A,
BOX WHEN (T1. C > 0) THEN (SELECT T2. C FROM T2 WHERE T1. C = T2. (A) T1 OTHERWISE. B END HAVE B,
T1. C
FROM T1;
OUTPUT:
A B C
-- -- ----------
X Y 1 - since c > 0 A and B values in table 2 are replaced
Z BB 2 - since c > 0 A and B values in table 2 are replaced
DF G 0 - since c = 0, there is even value in table 1
Post edited by: Parth272025
-
Duplicate records and modify data in another table
First of all, I have two tables (CUSTOMER and ADDRESS) with the following definition:
CUSTOMER has 7 columns (aa, ab, ac, ad, ae, af, ag)
AA is the primary key
AE, af, ag are the duplicate columns and he should be arrested by ae, af, ag
a foreign key between the CUSTOMER and ADDRESS
ADDRESS has 5 columns (bb, bc, bd, aa)
BB is the primary key
Here is an example of the content at the start
CUSTOMER
AA ab ac ad ae af ag
12 432 23 44 32 22 44
13 32 33 213 32 22 44
14 321 22 22 17 21 33
15 22 43 90 17 21 33
16 21 23 94 17 21 33
ADDRESS
BB bc bd be aa
17 321 33 23 12
18 123 32 22 13
20 22 23 34 14
21 22 21 22 15
22 12 34 22 16
And the result,
CUSTOMER
AA ab ac ad ae af ag
12 432 23 44 32 22 44
14 321 22 22 17 21 33
ADDRESS
BB bc bd be aa
17 321 33 23 12
18 123 32 22 12
20 22 23 34 14
21 22 21 22 14
22 12 34 22 14
How could I do with SQL?
Hello
user10681153 wrote:
...
INSERT INTO CUSTOMERS VALUES (12,432,23,44,32,22,44);INSERT INTO CUSTOMERS VALUES (13,32,33,213,32,22,44);
INSERT INTO CUSTOMERS VALUES (14,321,22,22,17,21,33);
INSERT INTO CUSTOMERS VALUES (15,22,43,90,17,21,33);
INSERT INTO CUSTOMERS VALUES (16,21,23,94,17,21,33);
INSERT INTO THE ADDRESS VALUES (17,321,33,23,12);
INSERT INTO THE ADDRESS VALUES (20,22,23,34,14);
INSERT INTO THE ADDRESS VALUES (21,22,21,22,15);
INSERT INTO THE ADDRESS VALUES (22,12,34,22,16);
In your original message, there are 5 rows in address; now, there are only 4. In light of these new data, I guess that the results you origianlly displayed for the customer are always the same, but the results that you want to start address are now:
BB BC BD BE AA
---------- ---------- ---------- ---------- ----------
17 321 33 23 12
20 22 23 34 14
21 22 21 22 14
22 12 34 22 14
I don't see anything wrong with my previous solution. Do you have?
-
Copy a column of data in another table?
Hello world
I am a beginner SQL who spent ridiculous amounts of time trying to find a solution to a problem no doubt very simple.
I have two tables composed of 162000 lines each. A table has the following format:
table T1
PID NUMBER
NUMBER OF PG
NUMBER OF PCS
PS NUMBER
NUMBER OF PL
NUMBER OF DRIFTWOOD
(coercion, but a simple data)
The DRIFTWOOD column is empty, all the others are completely filled.
The other table is filled only one column:
table T2
NUMBER OF CALCULATEDCHANCE
My intention is to copy all the rows in the column T2 CALCULATEDCHANCE in the column CYBERJER from T1.
Insert will not work because it adds records. I tried to use the update, but maybe I don't get the syntax right. All I got is to copy the first value of DRIFTWOOD in all lines of CALCULATEDCHANCE.
Thanks in advance for your answers!Try
update T2 set calculatedchance = dbms_random.value(0,100);
-
transfer data from a table to a new table
Hello all;
I have a table called infosight and I would like to create a new table called wall. I have in my infosight table, the columns and the following data
Now I want to insert only the following fields, * ID *, * place *, * price * in the new table called workzone until bookid value does not already exist in the wall table. Thank you. I would be grateful for all the help I can get. Thank you.bookid place author price 123 NewYork James $320.20 124 London John $356.56 125 Tokyo Hui $456.0
Try PLS,
insert into workzone (bookid, place , price) select bookid, place , price from infosight where bookid not in (select book_id from workzone)
or some other way,
Insert into the wall (bookid, place, price)
values
Select bookid, place, price of infosight where ID in
(select bookid infosight less
Select wall book_id)Published by: sree on July 25, 2010 06:59
-
Hello world
I have two tables, table 1 and table 2
Table1Columns: Name, phone number, address, JoinTime
Table2Columns: SeqNo, name, phone number, address, JoinTime
JoinTime is of type TimeStamp (0) sample data: 4 May 09 10.00.05.000000000 PM
I want to copy data from Table1 to Table2, SeqNo must be empty. How can I do it.
Any suggestions are appreciated.
Thank you
KasiYou can
insert into table2(SeqNo, LastName, Phone No, Address, JoinTime) select rownum AS SeqNo, LastName, Phone No, Address, JoinTime from table1 / -- // OR if you want to start from a particular number insert into table2(SeqNo, LastName, Phone No, Address, JoinTime) select 1000+ rownum AS SeqNo, LastName, Phone No, Address, JoinTime from table1 --// Sequence will start from 1001
SS
-
update of column based on the sum of the data from another table
I have two tables:
Table1 (col1, col2, col3, col4, val1, status) Table2 (col1, col2, col3, col4, val2)
For Table1 and Table2, column (col1, col2, col3, col4) are the primary key of composit.
Table2 could have duplicated lines, that's why I want to group by (col1, col2, col3, col4) and sum (val2)
After that, I want to update Table1.val1 with the value of sum (Table1.val2) where Table1.col1 = Table2.col1 and Table1.col2 = Table2.col2 and Table1.col3 = Table2.col3 and Table1.col4 = Table2.col4 and status = 'V '.
I did something like this:
UPDATE Table1 SET val1 = (
WHERE Table1.col1 = t_sommevbrute.col1 and Table1.col2 = t_sommevbrute.col2 and Table1.col3 = t_sommevbrute.col3 and Table1.col4 = t_sommevbrute.col4)
Could someone help me please? Thank you
merge into table1 t1
using (select col1, col2, col3, col4, sum (val2) val2
from table2
Group
by col1, col2, col3, col4) t2
on (t1.col1 = t2.col1 t1.col2 = t2.col2 and t1.col3 = t2.col3 and t1.col4 = t2.col4 and)
When matched then
update set t1.val1 = t2.val2;
-
on average + get data from another table
Hello..
I have two tables:
user_table: contains (user_id, username)
rating_table: contains (rating_id, side, user_id)
I am trying to create a view of the note for users...
the notice must contain:
the id, user_name, the average of the coast
I created the following script:
Select a.user_id, b.username, AVG (a.rate_value)
rating_bookstore a, user_bookstore b
where a.user_id = b.user_id
A.user_id group;
but I got the following error message:
ORA-00979: not a GROUP BY expression
any help is appreciated...
Kind regards...10 x 2 wrote:
Hello..I have two tables:
user_table: contains (user_id, username)
rating_table: contains (rating_id, side, user_id)I am trying to create a view of the note for users...
the notice must contain:
the id, user_name, the average of the coastI created the following script:
Select a.user_id, b.username, AVG (a.rate_value)
rating_bookstore a, user_bookstore b
where a.user_id = b.user_id
A.user_id group;but I got the following error message:
ORA-00979: not a GROUP BY expressionany help is appreciated...
Kind regards...Select a.user_id, b.username, AVG (a.rate_value)
rating_bookstore a, user_bookstore b
where a.user_id = b.user_id
A.user_id group, b.username; -
Transfer data to another disk group
Version: 10 gr 2
Platform: Sun OS 5.10
We have a database of CARS 2 knots with 4 terabyte of shared storage. Current size of the DB is only 1 TB stored in Diskgroup DATA1.
Can I create a new disk group and move all of the data in DATA1 (1 to) to the newly created disk group?
If this is not possible in 10 gr 2, is it possible in GR 11, 2?Hi Pete,.
Can I create a new disk group and move all of the data in DATA1 (1 to) to the newly created disk group?
I think the best way to do this is:
When you add new disks in the same diskgroup, and then remove the old drives.
ASM perform the automatic migration of data to new disks without having to create a new diskgroup, whitout donwtime. (on 10g you can do)If you need to rename the diskgroup in Oracle 11 g R2 you can do.
If this is not possible in 10 gr 2, is it possible in GR 11, 2?
Yes... its possible. (if you can migrate partial data)
http://www.idevelopment.info/data/Oracle/DBA_tips/Automatic_Storage_Management/ASM_36.shtml
Kind regards
Levi Pereira
Please close your message when you get the solution to your problem.
Check the answers answer 'useful' or 'right' answer which will help others with the same problem.
Thank you for doing your part to make this community as valuable as possible for everyone!
Maybe you are looking for
-
NB550D - HDTune Pro shows some issues on my HARD drive
Hello Today, I downloaded program HDTune Pro and when I looked into the health tap water there was some yellow lines.Below, I put a link to the print screen you could see that the error. I will be grateful if you could tell me what I should visit Tos
-
Tips for creating an application with web services please?
I created a simple application for a client who interacts / monitors a device VISA with LV 2009. The architecture is essentially a state machine with a timeout for VISA calls that retrieve the current state. The client asked that the app will also b
-
Access denied error connecting to the target RT
Hello I use LV2009 on a desktop host and RT 9 on a target PXI. I can connect to the target through the project with the original target embedded sw Explorer but cannot access the modules of IO MAX due to a driver version (DAQmx) inconsistancy betwee
-
7 modified Windows Explorer Navigation panel
One of my end user of Windows 7 Explorer Navigation Panel has changed. Normally there is the Navigation panel Favorites, Libraries, Computer Network. This user has Favorites Desktop Libraries, Computer Network How can I get it so that the computer li
-
Hi, I am new to using the SQLite database in blackberry, I copied the code from the sample of the weather, and I call the initializeDB() function, which calls for the openDB(). function openDB() {}If (db)return; If (! window.openDatabase) {}Alert ("b