Sequences
DBAsupport.com Forums - Powered by vBulletin
Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Sequences

  1. #1
    Join Date
    Jun 2003
    Posts
    47

    Question Sequences

    Hi everybody,

    Do I have to create for every table in the databsase a sequence in order to have values for the primary fields or there is some other way to that?

  2. #2
    Join Date
    Jul 2001
    Location
    Slovenia
    Posts
    422
    Yes, this is the common way.

    Of course, you can create a script to do it for you.
    Tomaž
    "A common mistake that people make when trying to design something completely
    foolproof is to underestimate the ingenuity of complete fools" - Douglas Adams

  3. #3
    Join Date
    Jun 2003
    Posts
    47

    Question sequences

    Can you show me how?

  4. #4
    Join Date
    Jan 2003
    Location
    Hull, UK
    Posts
    220
    Hi,

    CREATE SEQUENCE MY_SEQ START WITH 100
    INCREMENT BY 1
    NOMAXVALUE
    NOCYCLE
    CACHE 20;


    Its upto you to give the values,,or else it will take the default values.

    HTH

    SS

  5. #5
    Join Date
    Jan 2002
    Location
    Up s**t creek
    Posts
    1,525
    Create your sequence
    Code:
    CREATE SEQUENCE atable_s 
      START WITH 1 
      INCREMENT BY 1 
      NOMAXVALUE;
    Then use the sequence in your insert statements

    Code:
    INSERT INTO atable.col
      VALUES (atable_s.nextval);
    HTH
    Jim
    Oracle Certified Professional
    "Build your reputation by helping other people build theirs."

    "Sarcasm may be the lowest form of wit but its still funny"

    Click HERE to vist my website!

  6. #6
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712

    Re: Sequences

    Originally posted by edli
    Do I have to create for every table in the databsase a sequence in order to have values for the primary fields or there is some other way to that?
    It is possible to use one sequence for all tables, if you can live with gaps in primary keys. There's no requirement for table to have its own sequence.
    Ales
    The whole difference between a little boy and an adult man is the price of toys

  7. #7
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    Originally posted by TomazZ
    Yes, this is the common way.

    Of course, you can create a script to do it for you.
    No, If the database is designed properly all tables should have primary key column/s. Why to create dummy primary key values ?
    Sanjay G.
    Oracle Certified Professional 8i, 9i.

    "The degree of normality in a database is inversely proportional to that of its DBA"

  8. #8
    Join Date
    Nov 2002
    Posts
    80
    If the database is designed properly all tables should have primary key column/s. Why to create dummy primary key values ?
    hey I think u answered your own question

  9. #9
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    Originally posted by onlysimon
    hey I think u answered your own question

    Sanjay G.
    Oracle Certified Professional 8i, 9i.

    "The degree of normality in a database is inversely proportional to that of its DBA"

  10. #10
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Just to show that for every rule there is an exception, let me mention that in a data warehouse or DW fact table there is generally no requirement to define a PK, synthetic or otherwise, if the table os not the parent of another.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width