create table tablename ( id integer unsigned not null AUTO_INCREMENT, .... primary key id );
I need the primary key to start from 1000.
I'm using MySQL.
alter table yourTableName AUTO_INCREMENT=1; truncate table yourTableName; After doing the above two steps, you will get the primary key beginning from 1.
Primary Key Can be Zero, but if you set Identity on the column it normally will start at 1 rather than Zero. Primary Key will have Identity Column .. (Most likely or Most Scenario's) .. So Can i assume, if there is an identity Column we can start the seed / increment by 0.
Not all primary keys have to start at 1, as in the case of an order number. If the PK's are starting from different ranges then it helps in testing reports.
AUTO INCREMENT FieldAuto-increment allows a unique number to be generated automatically when a new record is inserted into a table. Often this is the primary key field that we would like to be created automatically every time a new record is inserted.
If your table has already been created with an auto-increment. so you can use
ALTER TABLE tbl AUTO_INCREMENT = 1000;
otherwise put the AUTO_INCREMENT = 1000;
in your CREATE TABLE
it goes before the final );
You can use ALTER TABLE to accomplish this:
ALTER TABLE tablename AUTO_INCREMENT = 1000;
If you want it as part of the CREATE TABLE
statement, just put it after the table definition:
CREATE TABLE tablename ( ... ) ENGINE=InnoDB AUTO_INCREMENT=1000;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With