Q
Problem solve Get help with specific problems with your technologies, process and projects.

Better way to update a column?

I have a table that contains nearly 3 million records; we added a new column to that table, which needs to be updated after some computation on existing columns from that table. Is there any better way to update the column rather than using a cursor and updating the values?

I have a table that contains nearly 3 million records; we added a new column to that table, which needs to be updated after some computation on existing columns from that table. Is there any better way to update the column rather than using a cursor and updating the values? For example:

For c in <<cursorname>> loop
some computation
update statement here
end loop;

Why use PL/SQL when a simple UPDATE statment will do the same work? A PL/SQL implementation of any UPDATE statement will take longer to complete. In some cases, such as millions of rows in the table, this difference can be quite noticable. I would try to code your operation as follows:
UPDATE TABLE SET new_column=(some computation);
Use PL/SQL only if you cannot write this as a single UPDATE statement.
This was last published in September 2005

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.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close