Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2002
    Posts
    4

    primary key generation

    The application I am writing must run on either SQL Server or Oracle.
    I want to know what the best approach is for generation of unique id's/primary key values in this case. One that is reliable and will scale.

    Currently I am generating my own 30 length varchar uuid.

    The problem I have with surrogate keys is that SQL Server does not migrate them very well and oracle requires different sql statement for sequences. I want to avoid writing db specific queries.

    I have been restricted from using stored procs or minimizing their use for migration and installation purposes. I think that if I have a valid enough argument, I could use a store proc to handle this.

    Any suggestions are appreciated.

    Second question:
    Will 30 varchar length field as a primary key cause performance problems on large tables?

    Thanks in advance.

  2. #2
    Join Date
    Jul 2001
    Location
    NC
    Posts
    102
    why don't you build your primary keys using multiple columms of your tables, such as:
    1) <lastName> + <firstName> + <midInit> + <ssNumb>
    2) <compName> + <div> + <office> + <state> + <city> + <accntNo>

  3. #3
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606
    Here is a Sybase document illustrating different primary key generation approaches.
    http://www.wallaceis.com/resource/ar...Generation.htm

    Sybase T-SQL and MS SQL T-SQL are very, very similar so it should provide some use.
    Thanks,

    Matt

  4. #4
    Join Date
    Feb 2002
    Posts
    4
    thanks, that was an excellent resource.

Posting Permissions

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