Home » SQL & PL/SQL » SQL & PL/SQL » SQL question (oracle 9.0.1)
SQL question [message #347013] Wed, 10 September 2008 07:39 Go to next message
rakeshforum
Messages: 5
Registered: September 2008
Location: india
Junior Member
Hi Everyone,

In one table there is one column ,in that column some data is there . my requirement is that one single update statement i have update this table like sequence of numbers like 1,2,3..100

for example
emp ->table
empno ->column
11
12
34
so on

only using update statement update this column
1
2
3
so on

please post me

Regards
Rakesh
Re: SQL question [message #347016 is a reply to message #347013] Wed, 10 September 2008 07:42 Go to previous messageGo to next message
joy_division
Messages: 4644
Registered: February 2005
Location: East Coast USA
Senior Member
You can use ROWNUM, but do know that the way you asked this question, you could just set it to an random number and you do not say whether they have to be unique.
Additionally, they will NOT be set to a sequence number in any defined order.
Re: SQL question [message #347017 is a reply to message #347013] Wed, 10 September 2008 07:43 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Also please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.

Regards
Michel
Re: SQL question [message #347021 is a reply to message #347013] Wed, 10 September 2008 07:52 Go to previous messageGo to next message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
The easiest way is to create a sequence and then use it to update the table

create sequence emp_s;

update emp
set empno=emp_s.nextval;
Re: SQL question [message #347034 is a reply to message #347021] Wed, 10 September 2008 08:30 Go to previous message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Easier than "set col=rownum"?

Regards
Michel

[Updated on: Wed, 10 September 2008 08:31]

Report message to a moderator

Previous Topic: Script to categorize the DJ aging
Next Topic: sql question
Goto Forum:
  


Current Time: Sat Dec 10 20:48:17 CST 2016

Total time taken to generate the page: 0.22788 seconds