How to Alter Multiple tables in a database using a single SQL Query

75
Views
1
Answers

Hi,
I have 250+ tables in my particular database, and i want to alter all the tables using a single query.
Suppose i want to add a column Total_Definition to all the tables of my database and i want to achieve the same using a single SQL Query.
Is it possible in SQL to Alter Multiple tables using one query.
If yes please guide at the earliest.

edit | flag
Ehtesham Siddiqui
Asked on: Mar 04, 2013 at 11:20AM

1 Answers

175
0
175

Adding a column in a database is not a query operation. It is a DDL (data definition language) operation. The best approach would be to use a PL/SQL or T/SQL procedure that uses a dynamic DDL statement to loop through each table to be altered.
Remember, any database hosted code that references the tables being altered, will likely be invalidated.

edit | flag
Simon Franklin
Answered on: Feb 20, 2014 at 2:27AM

Post your Answer

Search

Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags