Manage Learn to apply best practices and optimize your operations.

How to prevent overwriting data

I'm trying to insert data in a table from a remote database server to a local database server, but if an entry exists in the local server, I don't want the data to be overwritten. What command can perform this operation?
The INSERT operation will not overwrite any data in an Oracle database. If you insert two identical rows of data and you do not have a PRIMARY KEY (PK) constraint on your table, you will get two duplicate rows of data in the table. If the PK constraint exists, then the second INSERT operation will fail. In either case, no data is ever overwritten for an INSERT statement.

What some people are using in Oracle 9i is a new feature called the MERGE statement. This SQL statement will UPDATE an existing row with the new information or INSERT the information if the row does not previously exist. Maybe this is what you are referring to.

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.