Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help me

Status
Not open for further replies.

Mohammedkhamees

Programmer
Apr 29, 2007
1
EG
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?
thanks

Mohammed Sobhi
 
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.
 
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.

HTH

Leslie

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
 
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
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top