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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit on a key

Status
Not open for further replies.

TracerDX

Programmer
Joined
Jan 7, 2005
Messages
1
Location
US
I was wondering if there was a way, in MySQL, in a table definition, to set a "limit" on how big a key can get with auto_increment that's not based on data type.

More specifically, I'd like the key to be limited to 0-63 or 1-64 (the first prefered, but I know auto_increment starts at 1). The smallest integer data type is 255 values or 127 signed.

Basically, I want to be able to store these keys as a flag in a BIGINT which is limited to 64 possible flags. (If there are bigger precise data types, I'd love to know.)

I sifted thru the MySQL manual and found nothing.

Other solutions are welcome.

The requirement is to be able to store 0-* keys in a single column to be compared to a list of keys from other sources, and I think being able to use bitwise comparison is much more efficient than doing a script side cross-reference.

I could have the script manage the key, but if MySQL could do it for me, it would be that much more efficient.
 
start your tinyint auto_increment at 64, then you will only be able to add 63 more rows
Code:
create table t
( id tinyint not null primary key auto_increment
, foo varchar(11)
, bar integer
) auto_increment=64

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (course starts January 9 2005)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top