illuz1on Posted July 5, 2007 Share Posted July 5, 2007 Hey How would I add auto increacement to a ID field in a windows MySQL server? Thanks alot, illuz1on Link to comment https://forums.phpfreaks.com/topic/58518-solved-auto_increace-on-windows-mysql/ Share on other sites More sharing options...
Wildbug Posted July 5, 2007 Share Posted July 5, 2007 To create it in a new table: CREATE TABLE foo ( id INT UNSIGNED ZEROFILL AUTO_INCREMENT NOT NULL PRIMARY KEY, blah.... ); But you're adding this attribute, right? To add a new AUTO_INCREMENT integer column named c: ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY ©; Note that we indexed c (as a PRIMARY KEY), because AUTO_INCREMENT columns must be indexed, and also that we declare c as NOT NULL, because primary key columns cannot be NULL. When you add an AUTO_INCREMENT column, column values are filled in with sequence numbers for you automatically. For MyISAM tables, you can set the first sequence number by executing SET INSERT_ID=value before ALTER TABLE or by using the AUTO_INCREMENT=value table option. See Section 13.5.3, “SET Syntax”. With MyISAM tables, if you do not change the AUTO_INCREMENT column, the sequence number is not affected. If you drop an AUTO_INCREMENT column and then add another AUTO_INCREMENT column, the numbers are resequenced beginning with 1. Link to comment https://forums.phpfreaks.com/topic/58518-solved-auto_increace-on-windows-mysql/#findComment-290374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.