What is the command sequence for replacing values in table a with values in table b?
If the two tables are identical, and you want to completely replace contents of table a with table b, you could write a simple procedure to do the following steps:
- DELETE or TRUNCATE table A
- INSERT INTO table A SELECT * FROM table B
CREATE TABLE A as SELECT * FROM table B ;If you don't want to simply replace the entire contents, but want to match like rows and update, then you can write a statement or procedure to:
- Match all the rows of table B to their associated row (by key value) in table A
- When a match is found, replace the column values in table A with the values in table B
For More Information
- Dozens more answers to tough Oracle questions from Karen Morton are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig deeper on Oracle and SQL
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.