Update a table with primary key
Hello
I have a table called Temp
CREATE TABLE TEMP ( A VARCHAR2 (50 CHAR), B VARCHAR2 (50 CHAR), C VARCHAR2 (50 CHAR), D VARCHAR2 (18 CHAR), E DATE, F NUMBER, G VARCHAR2 (18 CHAR), H FLOAT );
The primary key is the PRIMARY KEY: (A, B, C, D, E, F, G).
I HAVE THE TEMPORARY TABLE 48052365 COUNTY,
HOWEVER I HAVE A REQUIREMENT TO UPDATE WHERE E (COLUMN) IS WEDNESDAY, THE SAME DAY IN MONDAY (I.E., C - 2 TO EXISTING DATE)
Approach;
I CREATED the TABLE TEMP_WED_TO_MONDAY AND SELECTED ALL THE RECORDINGS ELIGIBLE IN CE AND TABLE AND INDEX UNIQUE CREATED on this SUBJECT. TO UPDATE, I WROTE UNDER ANONYMOUS BLOCK.
Number of Tables: TEMP_WED_TO_MONDAY is 46,921,912 and count of total of the table is 48052365
Anonymous block:
DECLARE CURSOR UPDATE_TEMP_DATE IS SELECT A, B, C, D, E, F, G, E - 2 NEW_E FROM TEMP_WED_TO_MOONDAY; TYPE UPDATE_TEMP_DATE_REC IS RECORD ( A VARCHAR2 (50 CHAR), B VARCHAR2 (50 CHAR), C VARCHAR2 (50 CHAR), D VARCHAR2 (18 CHAR), E DATE, F NUMBER, G VARCHAR2 (50 CHAR), NEW_E DATE ); TYPE UPDATE_TEMP_DATE_TBL_TYPE IS TABLE OF UPDATE_TEMP_DATE_REC; UPDATE_TEMP_DATE_TBL UPDATE_TEMP_DATE_TBL_TYPE; BEGIN OPEN UPDATE_TEMP_DATE; LOOP FETCH UPDATE_TEMP_DATE BULK COLLECT INTO UPDATE_TEMP_DATE_TBL LIMIT 1000000; EXIT WHEN UPDATE_TEMP_DATE_TBL.COUNT = 0; FORALL I IN UPDATE_TEMP_DATE_TBL.FIRST .. UPDATE_TEMP_DATE_TBL.LAST UPDATE TEMP SET E = UPDATE_TEMP_DATE_TBL (I).NEW_E WHERE A = UPDATE_TEMP_DATE_TBL (I).A AND B = UPDATE_TEMP_DATE_TBL (I).B AND C = UPDATE_TEMP_DATE_TBL (I).C AND D = UPDATE_TEMP_DATE_TBL (I).D AND E = UPDATE_TEMP_DATE_TBL (I).E AND F = UPDATE_TEMP_DATE_TBL (I).F AND G = UPDATE_TEMP_DATE_TBL (I).G; COMMIT; END LOOP; CLOSE UPDATE_TEMP_DATE; END;
But for the past 6 hours, it only updated records 20,00,000(Twenty lakh) only. because this update in the table and is also part of the teaching primary key I think it takes time, but pointers to improve/acceleration of the update
Explain the plan:
update statement all_rows (Cost 4) 3 update hr.temp 2 table access by index rowid table hr.temp (Cost 4, Bytes : 64 ,Cardinality 1) 1 index range scan index hr.temp_wed_to_monday (Cost 3: Cardinality 1)
Thank you guys, I would be grateful if someone provides the solution for the scenario, rather than highlight the design. Please understand someone designed to best with whatever the limits it has during this period. (and this isn't me).
Tags: Database
Similar Questions
-
Mr President
My worm Jdev is 12.2.1.
I have master tables / details.
I have 2 lines for each PRIMARY KEY = ("VID", "LINEITEM") as below in the Details table.
Please help how to get a button on a jsf page to remove these two lines at a time.
Concerning
So, in your app (data model) module, you have a master relationship / typical retail:
And the relationship between them is based on some ViewLink
Now go to the ViewLink, relationship, accessor.
Take a look at the Destination accessor.
Generate accessor object to check and give a name Acessor
Then go to the master VO, Java and Include accessor, the class generate a display line:
Go to the class view Java generated line, you'll find a method with the name of the accessor of the previous step, in the form of:
public RowIterator getYourDetails...or_whaterever_IsAccessorName..() { }
Now, in the same Java class, write the following Java method:
public void removeDetails(){ RowIterator details = getYourDetails...or_whaterever_IsAccessorName..(); // it is RowIterator over all details Row r = details.first(); while (r != null) { r.remove(); r = details.next(); } }
This method on the Cilent export line Interface:
Finally, pass the data controls and drop this operation on the form as a button...
-
You would design Tables without primary key?
If you were asked to design a schema, if you create a table (however irrelevant) without a primary key? For example, a 'unprofessional' table such as a logging of errors table that records exceptions thrown from stored procedures, create you this table without a primary key?In a relational database you define und work with entities (tables) and you put in relationship to each other by joins. An entity must by definition always be identified by a unique key.
If you don't know what kind of unique key identifies your entries in the table, it is almost certain that working from home in your datamodel and table designs had not been made. Your database objects contain tables, and they must have a unique identifier. Often it is a primary key (PK) composed of several columns.By definition a datamodel that contains the tables without primary keys is nomore a relational datamodel and one of the fundamental bases for the creation of a relational database is violated.
Frankly I do not understand why Oracle allows the tables without primary key. Another system such as SAP R/3 are more stringent. Primary keys are required in the SAP and believe, when starting, it is sometimes tedious to define the primary key structures, but it's the basis of designing together relational datamodel you will put in place. You now SAP is based often on a DB ORACLE layer. They could do it, and these "extend" their functionality. But they are smart guys in Walldorf, and they always refrained to do. It's a good guess to believe, they have a good reason for it.
Tables without primary key are NO relational tables, they are dungpiles. As Oracle needs priimary key itself in order to operate a relational database, ROWID have been defined. ROWID is the primary keys of the tables where the customer does not have a PK. But nice as ORACLE is, they strongly recommend not to use these ROWID in the application or database layer. ROWID is no identifier object that are stable in time and space (eg. two different databases in a distributed design oder a DEV and PROD-system).
Definition of PK implies certain rules for the programming of your application and your DML operations. Especially you often MERGE in a relational table instead of simply INSERT'ing piece in a dungpile.
When it later on with SELECT large datavolumes dataaccess, again the differences between well-defined joins (all based on the PK-relations) and joins non-unique keys will be the order of magnitude. Not only that, the latest degrades in performance much more quickly with the growth of result sets. When you start fumbling with no UNIQUE INDEXES, speed up performance in the operations of dungpiling you are already closer to hell than on a sunny day in the world of relational data.
Othmar Lippuner
SQL Reporting professional -
Best way to update a table with separate values
Hi, I would really appreciate some advise:
I need to regularly perform a task where I update 1 table with all the new data that has been entered in another table. I cannot perform a complete insert because this will create data duplicated each time it works, so the only way I can think of is the use of cursors in the script below:
CREATE OR REPLACE PROCEDURE update_new_mem IS
tmpVar NUMBER;
CURSOR c_mem IS
SELECT nom_membre, member_id
OF gym.members;
CREC c_mem % ROWTYPE;
BEGIN
OPEN c_mem.
LOOP
SEEK c_mem INTO crec;
EXIT WHEN c_mem % NOTFOUND;
BEGIN
UPDATE gym.lifts
Name = crec.member_name
WHERE member_id = crec.member_id;
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
END;
IF SQL % NOTFOUND THEN
BEGIN
INSERT INTO gym.lifts
(name, member_id)
VALUES (crec.member_name, crec.member_id);
END;
END IF;
END LOOP;
CLOSE C_mem;
END update_new_mem;
This method works, but y at - it a (faster) easier way to update another table with new data only?
Thank you very much>
This method works, but y at - it a (faster) easier way to update another table with new data only?
>
Almost anything would be better than this treatment of slow-by-slow loop.You don't need a procedure, you should just use MERGE for this. See the examples in the section of the MERGER of the doc of the SQL language
http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_9016.htmMERGE INTO bonuses D USING (SELECT employee_id, salary, department_id FROM employees WHERE department_id = 80) S ON (D.employee_id = S.employee_id) WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01 DELETE WHERE (S.salary > 8000) WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus) VALUES (S.employee_id, S.salary*.01) WHERE (S.salary <= 8000);
-
Update of table with 14 million records
good day, I'm updating a table with 14 million documents column. using the data from another table.
This takes terrible time just updated to 500,000 over the weekend, which is unacceptable.
ideas to improve my code and get the fastest update is much appreciated.
DECLARE
TYPE vc_type is table of index varchar2 (20) by pls_integer;
type tabtype_rowid is table of pls_integer rowid indexes;
my_cur sys_refcursor;
cur_limit integer: = 10000;
tab_rowid tabtype_rowid;
Start
OPEN FOR My_cur
SELECT value, rowid
TABLE 1A
where the value IS NOT NULL
and id is null;
loop
collect the fetch my_cur in bulk in tab_value, cur_limit limit tab_rowid;
FORALL k IN 1.tab_npi.count
UPDATE table 1A
A.ID = (select id SET
in Table 2b
where value = tab_value (k)
and rownum = 1
)
WHERE a.rowid = tab_rowid (k);
COMMIT;
When the output tab_value.count < cur_limit;.
end loop;
END;
Thank you903537 wrote:
I tried to update basic training, as a first step and it crashed...He didn't fail, it failed.
-
Update of table with invalid identifiers
Hello!
I use a third-party plug-in and that comparisons of chemical structures. I want to update a table with the values of the other when the plugin matches two rows. However, I'm a problem invalid identifier.
Two tables:
PLATES: a VARCHAR2 columns of PLATE_SMILES, IN_DB
INVEST: a VARCHAR2 columns of SMILES
The operator is a binary: jc_compare (PLATE_SMILES, SMILES) = 1 (or 0 if they do not match)
I want my query to say: "If comparison SMILES, PLATE_SMILES = 1, define IN_DB = 1 for row" - effectively asking if PLATE_SMILES exists in the table INVEST.
I tried a number of "renditions", all identifiers not valid donations. Here is an example:
Update (select plate. PLATE_SMILES, plate. IN_DB, invest. SMILES
plate PLATES
INVEST invest
WHERE jc_compare (PLATE_SMILES, SMILES) = 1)
set plate. IN_DB = 1;
ORA-00904: "FLAT". "" IN_DB ": invalid identifier
I hope that this should be an easy fix, and any help is greatly appreciated!Hello
You have
UPDATE (SELECT plate.plate_smiles, plate.in_db, invest.smiles FROM plates plate, invest invest WHERE jc_compare ( plate_smiles, smiles) = 1) SET plate.in_db = 1; -- Error here
PLATE is not known outside the display online. Just remove it.
Concerning
Peter -
update of table with similar registration information using the same key
Version: 11.1.0.7.0
We have large table probably 30 M records
-test code table follows
create table people)
person_id number,
first name varchar2 (50).
middle_name varchar2 (50).
last_name varchar2 (50)
);
insert into persons (person_id, first_name, last_name, middle_name) values (1, 'JOHN', 'A', 'DOE');
insert into people (person_id, first_name, last_name, middle_name) values (1, 'JOHN', ","DOE");
insert into persons (person_id, first_name, last_name, middle_name) values (1, 'JOHN', 'ADAM', 'DOE');
insert into persons (person_id, first_name, last_name, middle_name) values (2, 'JOHN', ' C ', 'DOE');
insert into people (person_id, first_name, last_name, middle_name) values (2, 'JOHN', ","DOE");
insert into people (person_id, first_name, last_name, middle_name) values (3, 'JOHN', ","MOE");
insert into persons (person_id, first_name, last_name, middle_name) values (3, 'JOHN', 'FRANK', 'MOE');
I am trying to write more efficient code to take the middle name of the most complete and updated all records with the same KEY (person_id) with her.
Expected result:
1, JOHN, ADAM, DOE
1, JOHN, ADAM, DOE
1, JOHN, ADAM, DOE
2, JOHN, C., DOE
2, JOHN, C., DOE
3, JOHN, FRANK, MOE
3, JOHN, FRANK, MOE
Hello
Here is an example of the use of the aggregate LAST instead of the function ROW_NUMBER analytic function:
MERGE INTO dst people
WITH THE HELP OF)
WITH got_longest_middle_name AS
(
SELECT person_id
, MIN (middle_name) DUNGEON (DENSE_RANK LAST ORDER OF LENGTH (REPLACE (middle_name, '.')))
AS longest_middle_name
AMONG the people
WHERE middle_name IS NOT NULL
GROUP BY person_id
)
SELECT person_id
longest_middle_name
Got_longest_middle_name c - c is for candidates
WHERE DOES NOT EXIST)
SELECT 1
AMONG the people
WHERE person_id = c.person_id
AND c.longest_middle_name NOT AS REPLACE (middle_name, '.'). '%'
)
) src
WE (dst.person_id = src.person_id)
WHEN MATCHED THEN UPDATE
SET dst.middle_name = src.longest_middle_name
WHERE dst.middle_name <> src.longest_middle_name
OR dst.middle_name IS NULL
;
I suspect that this may be a little faster, but try it on your system with your data to make sure.
-
Help with primary key in table
Hello
I created a table in Oracle and it filled with information, but I need a primary key (such as an AutoNumber in Access) to identify each record. How can I do this for an existing table?
Thanks much for any help you can provide!Hello
You can leave down the old sequence and then create a new, or same but make sure that the sequence must be referenced in the trigger to generate IDs.
drop sequence
; Let me know if its works for you or not.
concerning
Published by: OrionNet on March 9, 2009 20:50
-
addition of populated table's primary key column
Hi all
I am trying to add a column to a table that is already filled. The column to be added must be the primary key.
As expected, oracle jumped to the top of the error (ORA-01758) of a column NOT NULL cannot be added, unless the table is empty.
A possible way is to create a new temp table and then transfer all current data... rename the temporary table later.
Is there another way to accomplish this?
Thank youHello
As error suggested you cannot add a constraint not null on the new column to the table that is already filled. What else you can do next to you, you have a fairly simple and fast to create a temporary table and moving data?
You can add the new column but null, update the column with values and alter the table of marking column as not null. But your idea of empty temporary table is simple and fast.CREATE TABLE my_objects AS SELECT 'my_new_column' my_new, owner FROM all_objects WHERE ROWNUM < 1; _Not Null_ ALTER TABLE MY_OBJECTS MODIFY(MY_NEW NOT NULL); _Primary key_ ALTER TABLE MY_OBJECTS ADD CONSTRAINT MY_OBJECTS_PK PRIMARY KEY (MY_NEW);
Concerning
-
Get 2 amounts of 2 columns of 2 tables without primary key
I would like to get the sum of column A of table 1 and the sum of column D in table 2 without using the primary key.
Because I can't link the two tables, the only corresponding value is not the primary key.
TABLE 1
COLUMN A. COLUMN B | COLUMN C
PAID NUMBER DESCRIPTION
15472 blabla1 S15-875
18515 S15-875 blabla1 215526.52 blabla2 D17-517
... ... ...
TABLE 2
COLUMN D | COLUMN E | COLUMN F
INVOICE NUMBER DESCRIPTION 185525 blabla1 S15-875
158520 D17-517 blabla2
8964 D17-517 blabla2
I would like to see the number, the sum of which should be paid and what has been paid.
But as you can see, you can pay in several times and there may be several invoices.
There is therefore no link between two tables which is a primary key in both entities.
No idea how I could get it?
NUMBER | DESCRIPTION | BILL | PAID
S15-875 185525 33987 blabla1
D17-517 blabla2 167484 215526.52
The tables can be attached on «NUMBER», regardless of weather conditions, as a primary key is defined.
sql> with table_1 as 2 ( select 15472 as paid, 'S15-875' as "NUMBER", 'blabla1' as description from dual 3 union all select 18515 as paid, 'S15-875' as "NUMBER", 'blabla1' as description from dual 4 union all select 215526.52 as paid, 'D17-517' as "NUMBER", 'blabla2' as description from dual 5 ) 6 , table_2 as 7 ( select 185525 as invoice, 'S15-875' as "NUMBER", 'blabla1' as description from dual 8 union all select 158520 as invoice, 'D17-517' as "NUMBER", 'blabla2' as description from dual 9 union all select 8964 as invoice, 'D17-517' as "NUMBER", 'blabla2' as description from dual 10 ) 11 select t1."NUMBER" as "NUMBER" 12 , t1.description as description 13 , ( select sum(t2.invoice) from table_2 t2 where t2."NUMBER" = t1."NUMBER" ) as invoice 14 , sum(t1.paid) as paid 15 from table_1 t1 16 group by t1."NUMBER" 17 , t1.description 18 / NUMBER DESCRIP INVOICE PAID ------- ------- ---------- ---------- D17-517 blabla2 167484 215526.52 S15-875 blabla1 185525 33987
BTW: 'NUMBER' is a horrible name for a column. I strongly recommend to change something that is not a reserved word.
-
Great advice table no primary key on the table.
Dear gurus,
Version: Oracle 11.2.0.3.0 running on Linux HAVE 6.
I have a big standard table (400 million lines) which is a data dump, it was created with no primary key Yes crazy but it happens (very rare). I have a few key columns indexed for the purpose of the motion, but I would like to know what are the options I have different indexing on a table to make it more efficient for running a query against it.
Looking for simple opinion where further research. I won't not give an example of the table structure - neither include the details, I'm looking for advice.
Easy points for everyone.
Thank you.
-
Update a table with one column of another
Oracle 11g
Helloi'im trying to update the two columns of table SUPPORT (SUPPORT_X, SUPPORT_Y) with two columns of table POST_HTA_BT (POSTHTABT_GPS_X, POSTHTABT_GPS_Y)
Understand that the two tables have the colum below:
SUPPORT (SUPPORT_ID, SUPPORT_PLAQUE, POSTHTABT_ID, SUPPORT_X, SUPPORT_Y,...)
POST_HTA_BT (POSTHTABT_ID, POSTHTABT_GPS_X, POSTHTABT_GPS_Y,...)
The SUPPORT_PLAQUE has type varachar. Except the keys, the other columns are varchar type in both tables.
The point here is to update the support_x, support_y with posthtabt_gps_x and posthtabt_gps_y.But before the update we have Sheik if the fifth number of the support plate is a number of characters from "0" to "9"and the rest of the caracter of the support_plaque is '00000'
Please note that the support_plaque is stored in the table with the form: "0025800000!"
So I did the below script, I try to execute in sql develop.
SET SERVEROUTPUT ON
DECLARE
chiffre_liste varchar (200): = '0 ', '1', '2', '3', '4', ' 5 ', ' 6' ', 7', ' 8 ', ' 9';
CURSOR CUR_GPS_SUPPORT IS
Select MEDIA. SUPPORT_X, SUPPORT. SUPPORT_Y, POSTE_HTA_BT. POSTHTABT_ID, SUPPORT. EXPL_ID,
SUPPORTED. SUPPORT_PLAQUE, POSTHTABT_GPS_X, POSTHTABT_GPS_Y
support,.
POSTE_HTA_BT
where
SUPPORTED. SUPPORT_X IS NULL and
SUPPORTED. SUPPORT_Y IS NULL and
SUPPORTED. POSTHTABT_ID = POSTE_HTA_BT. POSTHTABT_ID and
SUPPORTED. EXPL_ID = POSTE_HTA_BT. EXPL_ID
Order of SUPPORT. POSTHTABT_ID;w_POSTHTABT_ID POSTE_HTA_BT. Type of POSTHTABT_ID %;
w_SUPPORT_X SUPPORT. TYPE % SUPPORT_X;
w_SUPPORT_Y SUPPORT. TYPE % SUPPORT_Y;
w_EXPL_ID SUPPORT. TYPE % EXPL_ID;
w_SUPPORT_PLAQUE SUPPORT. TYPE % SUPPORT_PLAQUE;
w_POSTHTABT_GPS_X POSTE_HTA_BT. TYPE % POSTHTABT_GPS_X;
w_POSTHTABT_GPS_Y POSTE_HTA_BT. TYPE % POSTHTABT_GPS_Y;BEGIN
DBMS_OUTPUT. Put_line ('loading the coordoonnees GPS - GPS Coord update takes care of starting ');FOR HEART LOOPING CUR_GPS_SUPPORT
w_POSTHTABT_ID: = cur. POSTHTABT_ID;
w_SUPPORT_PLAQUE: = cur. SUPPORT_PLAQUE;
w_SUPPORT_X: = cur. SUPPORT_X;
w_SUPPORT_Y: = cur. SUPPORT_Y;
w_POSTHTABT_GPS_X: = cur. POSTHTABT_GPS_X;
w_POSTHTABT_GPS_Y: = cur. POSTHTABT_GPS_X;If substr (cur.support_plaque, 5, 1 chiffre_liste) and substr (cur.support_plaque, 6, 5) = '00000'
w_SUPPORT_X: = CUR. POSTHTABT_GPS_X
w_SUPPORT_Y: = CUR. POSTHTABT_GPS_Y
END if;
EXCEPTION WHEN NO_DATA_FOUND THEN w_SUPPORT_X: = NULL and w_SUPPORT_Y: = NULL;
END;-Updated the table of the supports
Update SUPPORT
Set SUPPORT_X = w_SUPPORT_X,
SUPPORT_Y = w_SUPPORT_Y
where SUPPORT_PLAQUE = w_SUPPORT_PLAQUE;
-On valid imm? immediately
commit;
EXCEPTION when no_data_found then null;
-No details found
END;
END;
/and I got the following errors:
Error report:
ORA-06550: line 2, colum 34:
PLS-00103: symbol ',' met instead of one of the following symbols:* & = - + ; <>/ is mod remains not rem
<>< Hurst (*) > or! = or ~ = > = < = <>and like2 or
like4 likec between | submultiset of type multiset Member
ORA-06550: line 2, column 52:
PLS-00103: symbol ';' met instead of one of the following symbols:), * & = - + <>/ is mod remains not rem = >
<>< Hurst (*) > or! = or ~ = > = < = <>and like2 or
like4 likec between | Member of multiset must
ORA-06550: line 38, colum 48:
PLS-00103: symbol 'CHIFFRE_LISTE' met instead of one of the following symbols:(
Symbol "(" a été substitué à "CHIFFRE_LISTE" verser continuer.) "
ORA-06550: line 39, 12 colum:
PLS-00103: symbol 'W_SUPPORT_X' met instead of one of the following symbols:), * & -+ / at rem mod < Hurst (*) > rest and or.
multiset
ORA-06550: line 40, 12 colum:
PLS-00103: symbol 'W_SUPPORT_Y' met instead of one of the following symbols:. (), * @ % & = - + <>/ is mod remains not rem
<>< Hurst (*) > or! = or ~ = > = < = <>and like2 or
like4 likec between | mult
ORA-06550: line 41, colum 9:
PLS-00103: symbol 'END' met instead of one of the following symbols:. (), * @ % & = - + <>/ is mod remains not rem
<>< Hurst (*) > or! = or ~ = > = < = <>and like2 or
like4 likec between | multiset members
06550 00000 - "line %s, column % s:\n%s".
* Cause: Usually a PL/SQL compilation error.
* Action:I checked the line number, but do not see the error in my code.
Please could you help me?
peace
Hello
glad to know that it worked. In fact, I don't see the reason to make these complicated processes.
Remember the mantra:
- If you can do it with SQL then do it with SQL
Good evening!
Alberto
-
How to insert multiple lines in viewobject with primary key?
Hello
I use Jdeveloper 11.1.1.3.0 version.
I create object entity based on the table of the database that have primary keys.
I created the view on this entity object. I created an array of viewobject, with CreatInsert button and my primary key in the table may while the new record is added.
Now my problem is that I have created several rows by pressing CreateInsert Button several rows of time are created and displayed in the table. I insert data in all columns of all rows when I click on the submit button (who have the Action "# {bindings.Commit.execute} ') will save data of any 1 line not all data line.
How can I save all the lines that is created in a single transaction?
Thanks in advance
AmitAmit,
I just tried this (all by default, no code written), and he recorded all of the lines. It must be something unique to your application. Michael asks a lot of questions.
John
-
How to update the table with the number management
Hello
I need as there is a loc_tab of the created table as below,
CREATE TABLE loc_tab
(
Country_ID NUMBER,
country_code VARCHAR2 (3),
country_name VARCHAR2 (50).
State_ID NUMBER,
state_code VARCHAR2 (3),
state_name VARCHAR2 (50).
city_id NUMBER,
city_code VARCHAR2 (3),
city_name VARCHAR2 (50)
);
I inserted records like below,
Now, I wanted to update the table such that all ID columns are updated with running number.COUNTRY_ID COUNTRY_CODE COUNTRY_NAME STATE_ID STATE_CODE STATE_NAME CITY_ID CITY_CODE CITY_NAME IND INDIA TN TAMIL NADU CHN CHENNAI IND INDIA TN TAMIL NADU TRI TRICHY IND INDIA TN TAMIL NADU CMT COIMBATORE IND INDIA TN TAMIL NADU MDU MADURAI IND INDIA AP ANDHRA PRADESH HYD HYDERABAD IND INDIA AP ANDHRA PRADESH SEC SECUNDRABAD AUS AUSTRALIA QLD QUEENSLAND BRI BRISBANE AUS AUSTRALIA TAS TASMANIA HB HOBART AUS AUSTRALIA TAS TASMANIA CCE CITY OF CLEARANCE AUS AUSTRALIA TAS TASMANIA BUR BURNIE
Each ID columns should get incremented so that, for Country_ID column corresponding to "India" If country_id is 1, that there must be one for all the lines with the name as "India". Likewise for "Australia".
In the case of State, she also has the same logic with numbers repeated until the very name of the State comes.
For the city, it of course will hold separate ID only because the name of the city will not get duplicated.
This update must be done in the normal way using simple SQL such as no PLSQL don't like looping, etc... is involved.
Here are the contents of the table, and that's how the table should be updated,
Thank you and best regards,COUNTRY_ID COUNTRY_CODE COUNTRY_NAME STATE_ID STATE_CODE STATE_NAME CITY_ID CITY_CODE CITY_NAME 1 IND INDIA 1 TN TAMIL NADU 1 CHN CHENNAI 1 IND INDIA 1 TN TAMIL NADU 2 TRI TRICHY 1 IND INDIA 1 TN TAMIL NADU 3 CMT COIMBATORE 1 IND INDIA 1 TN TAMIL NADU 4 MDU MADURAI 1 IND INDIA 2 AP ANDHRA PRADESH 1 HYD HYDERABAD 1 IND INDIA 2 AP ANDHRA PRADESH 2 SEC SECUNDRABAD 2 AUS AUSTRALIA 1 QLD QUEENSLAND 1 BRI BRISBANE 2 AUS AUSTRALIA 2 TAS TASMANIA 1 HB HOBART 2 AUS AUSTRALIA 2 TAS TASMANIA 2 CCE CITY OF CLEARANCE 2 AUS AUSTRALIA 2 TAS TASMANIA 3 BUR BURNIE
Shiva
-
Potential problems for tables without primary keys and unique keys
GoldenGate 11.2.1.0.3/Solaris 10
DB: Oracle for Oracle (Source and target is 11.2.0.3)
Topology: unidirectional
In our one-way configuration GG, little of the tables being replicated is not a primary key or a Unique key.
Last week when we have implemented GG for the test, we received warnings for these table below.
Replication seems to work very well for these tables.GGSCI > add trandata WMHS_UD.crtn_dtl 2013-01-12 11:34:33 WARNING OGG-00869 No unique key is defined for table 'CRTN_DTL'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key. Logging of supplemental redo data enabled for table WMHS_UD.crtn_dtl.
Googling, I think that there may be performance degradation when you replicate tables without PK or the United Kingdom.
But are there other potential problems such as data of a certain kind not replicated to the lack of PK/UK?It really depends on the data.
By default, GG is combining all columns as a virtual primary key but don't no conflict control by default. So when you can be sure that the record you insert into the table is unique, then it will work.
BUT as soon as you insert the same record, which is already inserted, then you will encounter problems.Let me show what happens when you use an initial charge because it makes it easier to describe:
We start at 10:00 the capture for a table. Now, you insert a record at 10:00 in the tables. When you now start an initial charge to 10.02, then check you have inserted in the database to 10.01 will be repeated two times. During the IPL as the initial charge is made to 10.02 and it includes data of 10.01 AND it will be replicated again through the process of capture/replicate.
Maybe you are looking for
-
HP Pavilion g6-1384sa - SATA I, SATA II or SATA III?
What versions of SATA HDD the HP Pavilion 1384sa g6 does support? Thank you.
-
It of maybe a stupid question... but is it possible to connect two controls so that they affect to another? More precisely: I control A and B and want to make the $ 10. Order change A will affect the display of B in real time and vice versa.
-
Hi, I bought a laptop S400 Touch 2 months back. Now, it says my Windows is about to expire, and she asked an activation key. I don't have any activation code. How can I get rid of this problem. And also my contact does not work properly. How can I ge
-
I get this message: "Currently you are not allowed to access this folder." How can I get permission? This happens in several places. Thanks. - doc
-
HP Pavilion HDX9095EA and Windows 7 drivers (including: TV card)
Greetings. I have HP Pavilion HDX9095EA, with the following specifications: Intel Core 2 Duo T7500 2.2 GHz Cache2: 4 MB. ATi Mobility Radeon HD2600, HARD drive 400GO (updated 1 TB - 2 x 500 GB), memory 2 GB (upgrade to 4 GB), Windows Vista Home Premi