Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Please Help me

Please Help me

Please Help me

I want to make a column in a certain table ,this column consists of 3 chars an 6 autoincrement numbers like "abc-123456" .Furthermore this column is a primary key

how can i do this?

Mohammed Sobhi

RE: Please Help me

depends very much on the database you use. Most support an autoincrementing integer field, so I would not try to have this value in one field, instead have two seperate fields and use a view to combine these two fields.

Bye, Olaf.

RE: Please Help me

however, if you need the number to be sequential or if you need to assign some "meaning" to the number, you shouldn't use an autoincrementing.

Search the forum for the database you're using and post in that specific forum.



Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins

RE: Please Help me

I would create a generic primary key, just an autosequence.

Then I would create two additional columns.  One with the 3 character fields and another with the autoincrementing  sequential number. Then make an index on the combined (concatenated) columns and place a unique constraint on it.

The trouble with doing something right the first time is that nobody appreciates how difficult it was - Steven Wright

RE: Please Help me

I like those ideas, John: a synthetic primary key AND a composite alternate key.  Particularly because the requirements for the char+serial business are unknown, and might not be uncovered until after the thing is implemented.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close