[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL to increment number by 1

Posted on 2009-04-02
7
Medium Priority
?
1,171 Views
Last Modified: 2012-05-06
I like a simple Oracle SQL like the following so each run I will get a increment number by 1.  Please help.  It can be a sequence or anything you can think of.  Thanks.

select myseq from dual;

001
002
003
...
998
999
0
Comment
Question by:ewang1205
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 40

Assisted Solution

by:mrjoltcola
mrjoltcola earned 1400 total points
ID: 24051892
create sequence myseq start with 1 increment by 1;

select myseq.nextval from dual;
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 200 total points
ID: 24051896
in what context to you need this?
please clarify.
0
 

Author Comment

by:ewang1205
ID: 24051919
squence number will be 1, 2, 3 not 001, 002,003.  

in what context to you need this?  This is just a SQL.  

Thanks.
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 40

Accepted Solution

by:
mrjoltcola earned 1400 total points
ID: 24051941
select to_char(myseq.nextval, '000') from dual;
0
 
LVL 23

Assisted Solution

by:David
David earned 400 total points
ID: 24051971
Or for a table insertion, ... values( myseq.nextval), col b, ....)
0
 
LVL 40

Assisted Solution

by:mrjoltcola
mrjoltcola earned 1400 total points
ID: 24051995
Not sure what context you mean by "sql" but your requirement limits your sequence to 000 - 999, thats expected, right?
0
 

Author Closing Comment

by:ewang1205
ID: 31565880
Thanks for the solution.  
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to recover a database from a user managed backup

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question