Home » SQL & PL/SQL » SQL & PL/SQL » Oracle SQL (11G Express Edition)
Oracle SQL [message #648842] Fri, 04 March 2016 10:20 Go to next message
mcdinesh.200@gmail.com
Messages: 18
Registered: March 2016
Junior Member
Hi,


How can i add a new column in one table from another table in Alter table statement.

If there is any possibilities kindly let me know.



Thanks in Advance,
Dinesh Kumar
Chennai.
Re: Oracle SQL [message #648843 is a reply to message #648842] Fri, 04 March 2016 10:25 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

If you mean in one statement, No.

[Updated on: Fri, 04 March 2016 10:26]

Report message to a moderator

Re: Oracle SQL [message #648932 is a reply to message #648843] Mon, 07 March 2016 16:18 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
You have to alter the table and then update the column using a join, for example the following would work if you have someway to join the first table row to the second table row.

update table mytable add col23 varchar2(40);

update mytable a
set col23 =
(select colx
from MyOtherTable b
where a.id = b.id);
Re: Oracle SQL [message #648943 is a reply to message #648932] Tue, 08 March 2016 04:24 Go to previous messageGo to next message
gazzag
Messages: 1118
Registered: November 2010
Location: Bedwas, UK
Senior Member
Bill B wrote on Mon, 07 March 2016 22:18

update table mytable add col23 varchar2(40);

Should obviously be:
ALTER table mytable add col23 varchar2(40);
Re: Oracle SQL [message #648945 is a reply to message #648943] Tue, 08 March 2016 07:48 Go to previous message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
LOL. Sorry for the typo.
Previous Topic: row to column
Next Topic: MultiSet Operations on PL/SQL Tables
Goto Forum:
  


Current Time: Thu Apr 25 03:26:29 CDT 2024