Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

For Each Loop PL/SQL

Kodiak_SeattleOct 14 2010 — edited Oct 15 2010
I am slowly learning PL/SQL, I have some programming experience using Visual Basic for Excel, so I am not totally in the dark, but not really sure :-)

Here is what I am trying to do, am on 10g by the way.

I have about 10+ Tables in my schema, with pretty much the same structure and I know that I could use plain SQL to do this with, but I want to learn PL/SQL.

So, I have 10+ tables where I have to add a new field of type varchar2(100), I was wondering if I could employ the FOR LOOP or maybe something better, list all the Tables that I need to ALTER and say:

For each Table from list
LOOP
alter table table_name add KEY varchar2(100);
END LOOP;

I have the full list of the Tables, what do you guys think ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 12 2010
Added on Oct 14 2010
27 comments
72,567 views