Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6886329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:44:45+00:00 2026-05-27T05:44:45+00:00

I know how to create a sequence in pl sql. However, how would I

  • 0

I know how to create a sequence in pl sql. However, how would I set the values to all have say 3 digits? is there another sql statement to do this when I create a sequence?

so an example would be:

000
001
012
003

Thanks guys!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:44:45+00:00Added an answer on May 27, 2026 at 5:44 am

    First, just to be clear, you do not create sequences in PL/SQL. You can only create sequences in SQL.

    Second, if you want a column to store exactly three digits, you would need the data type to be VARCHAR2 (or some other string type) rather than the more common NUMBER since a NUMBER by definition does not store leading zeroes. You can, of course, do that, but it would be unusual.

    That said, you can use the “fm009” format mask to generate a string with exactly 3 characters from a numeric sequence (the “fm” bit is required to ensure that you don’t get additional spaces– you could TRIM the result of the TO_CHAR call as well and dispense with the “fm” bit of the mask).

    SQL> create table t( col1 varchar2(3) );
    
    Table created.
    
    SQL> create sequence t_seq;
    
    Sequence created.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  insert into t
      2    select to_char( t_seq.nextval, 'fm009' )
      3      from dual
      4*  connect by level <= 10
    SQL> /
    
    10 rows created.
    
    SQL> select * from t;
    
    COL
    ---
    004
    005
    006
    007
    008
    009
    010
    011
    012
    013
    
    10 rows selected.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know the statement: create table xyz_new as select * from xyz; Which copies
I know that having diamond inheritance is considered bad practice. However, I have 2
Learning clojure, trying to create a lazy infinite sequence of all prime numbers. I'm
How can I create a leading zero sequence in PostgreSQL? For MySQL I know
I am trying to create a sequence in oracle sql, using the minvalue as
What kind of skills should a WPF developer know to create MVVM applications? Things
I know how to create a SEL at compile time using @selector(MyMethodName:) but what
Anyone know how to create a routed event in Silverlight 2? In WPF, the
I know how to create a custom user control in WPF but how can
Anyone know how to create a division like the the ones used in Google

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.