Home » SQL & PL/SQL » SQL & PL/SQL » DDL Trigger
icon9.gif  DDL Trigger [message #299519] Tue, 12 February 2008 05:29 Go to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member


I want to alter a table AQ to add a field S ;table AQ have 100 records i want to insert values in field S using trigger (is there any other method other than using trigger )at the time of table alteration itself .
Please help me


Thanks in Advance Smile
Re: DDL Trigger [message #299525 is a reply to message #299519] Tue, 12 February 2008 05:46 Go to previous messageGo to next message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member
there's no way you can update all the rows using the alter table command even if you added the DEFAULT clause. only those rows inserted afterwards will have that default values.why not just add the column and update it with a desired value?

[Updated on: Tue, 12 February 2008 05:47]

Report message to a moderator

Re: DDL Trigger [message #299531 is a reply to message #299525] Tue, 12 February 2008 06:01 Go to previous messageGo to next message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member
i take back my earlier statement.
Quote:
there's no way you can update all the rows using the alter table command even if you added the DEFAULT clause. only those rows inserted afterwards will have that default values


in fact if you add a default clause that new col will be updated with that value.



regards,

[Updated on: Tue, 12 February 2008 06:04]

Report message to a moderator

Re: DDL Trigger [message #299535 is a reply to message #299531] Tue, 12 February 2008 06:11 Go to previous messageGo to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member



No Sir , i want to insert different values in the field S
Re: DDL Trigger [message #299536 is a reply to message #299519] Tue, 12 February 2008 06:22 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
is there any other method other than using trigger

Fill the field the INSERT statement.

Regards
Michel
Re: DDL Trigger [message #299537 is a reply to message #299535] Tue, 12 February 2008 06:24 Go to previous messageGo to next message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member
Quote:
i want to insert different values in the field S

what is the source of your differnt values?
- is it a result of some calculation.
- from some other table/s.
can you be more precise?

regards,
Re: DDL Trigger [message #299542 is a reply to message #299537] Tue, 12 February 2008 06:36 Go to previous messageGo to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

No Sir, That field is a unique key and i want to start value from 1
Re: DDL Trigger [message #299543 is a reply to message #299542] Tue, 12 February 2008 06:42 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
update your_table
set    s = rownum;


For future rows, you will need a sequence.
Previous Topic: execute query in sqlplus
Next Topic: Varchar2 as Primary Keys
Goto Forum:
  


Current Time: Fri Dec 09 23:22:01 CST 2016

Total time taken to generate the page: 0.13131 seconds