How to Set Auto Increment Value In MySQL

104 6
    • 1). Access your MySQL table and go to the portion where you created your table. It should resemble this:

      CREATE TABLE customers (

      ident MEDIUMINT NOT NULL,

      NAME CHAR(20) DEFAULT '' NOT NULL,

      PRIMARY KEY(ident)

      );

    • 2). Insert the text "AUTO_INCREMENT" on the primary key "ident" line. Change the code for your specific table accordingly.

      CREATE TABLE customers (

      ident MEDIUMINT NOT NULL AUTO_INCREMENT,

      NAME CHAR(20) DEFAULT '' NOT NULL,

      PRIMARY KEY(ident)

      );

    • 3). Save your database changes. The table will increment the "ident" field automatically.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.