in Microsoft sql server 2005 or later,it is easier to generate unique numbers using the database server directly. you only specify the IDENTITY specification say 10000 and an incremental value say 1. this will generate numbers from 10000 upwards and at no time a number can be repeated or used by a different row(even if you delete sql will count the last number as being used and point next).
How can you do that using mysql server ? my aim is to auto-generate uniform and sequential numbers by using the database server itself.


...sorry for my bad english.. i speak kirwanda.

Recommended Answers

All 2 Replies

To start at a value other than 1, add

AUTO_INCREMENT xxxxx

to a create query, like CREATE TABLE bla (this and that) AUTO_INCREMENT 1000

Below is query.

ALTER TABLE `tbl_name` AUTO_INCREMENT =1000 ;

Once you run this query, next auto id in tbl_name will be 1000.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.