Home » SQL & PL/SQL » SQL & PL/SQL » Query to alter mass number of tables
Query to alter mass number of tables [message #392430] Wed, 18 March 2009 00:09 Go to next message
nipa.pillai
Messages: 11
Registered: February 2009
Junior Member
I have stored the names of the tables in a table say tablelist in my database. I want a alter table query which would add columns in the tables mentioned in tablelist.

Please help..
Re: Query to alter mass number of tables [message #392431 is a reply to message #392430] Wed, 18 March 2009 00:11 Go to previous messageGo to next message
BlackSwan
Messages: 25042
Registered: January 2009
Location: SoCal
Senior Member
> I want a alter table query which would add columns in the tables mentioned in tablelist.
So proceed to do so.

You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
Re: Query to alter mass number of tables [message #392432 is a reply to message #392430] Wed, 18 March 2009 00:15 Go to previous messageGo to next message
nipa.pillai
Messages: 11
Registered: February 2009
Junior Member
If i know the way to proceed i would not have asked this question here..
Re: Query to alter mass number of tables [message #392434 is a reply to message #392430] Wed, 18 March 2009 00:20 Go to previous messageGo to next message
BlackSwan
Messages: 25042
Registered: January 2009
Location: SoCal
Senior Member
You have table & DDL. We don't
You have data & DML. We don't.
You have code. We don't.

You have ALL the information & can't debug the problem.
Why do you expect others, who have NO details, to answer your mystery?

Re: Query to alter mass number of tables [message #392459 is a reply to message #392430] Wed, 18 March 2009 01:31 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Build a string with the statement you want to execute and use "execute immediate" to execute it.

Regards
Michel
Re: Query to alter mass number of tables [message #392461 is a reply to message #392430] Wed, 18 March 2009 01:55 Go to previous messageGo to next message
nipa.pillai
Messages: 11
Registered: February 2009
Junior Member
SELECT 'ALTER TABLE' || ' ' || tablename ||' ' || 'Add session_id varchar2(15)'
FROM scott.tablelists;


What if i want to execute this statement?
Re: Query to alter mass number of tables [message #392462 is a reply to message #392461] Wed, 18 March 2009 02:00 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
In which context?

Regards
Michel
Re: Query to alter mass number of tables [message #392467 is a reply to message #392430] Wed, 18 March 2009 02:07 Go to previous messageGo to next message
nipa.pillai
Messages: 11
Registered: February 2009
Junior Member
The same as in what i asked in the beginning.
What i want is to alter a list of tables mentioned in tablelists.
This query works but it returns me the string. It does not execute it.
Re: Query to alter mass number of tables [message #392469 is a reply to message #392459] Wed, 18 March 2009 02:16 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Michel Cadot wrote on Wed, 18 March 2009 07:31
Build a string with the statement you want to execute and use "execute immediate" to execute it.

Regards
Michel


This clearly described two steps..
Re: Query to alter mass number of tables [message #392472 is a reply to message #392469] Wed, 18 March 2009 02:24 Go to previous message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
I would spool the output of the select statement in a .sql file and call that .sql file afterwards.

Here's an old example I wrote on dropping tables. The principle is the same. Instead of user_tables, use your tablelist.

MHE
Previous Topic: Multiple Cursors
Next Topic: How to know the column name used in query?
Goto Forum:
  


Current Time: Wed Dec 07 02:46:51 CST 2016

Total time taken to generate the page: 0.17785 seconds