Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AUTOINCREMENT not automatically adding values in Mysql Workbench IDE

I am learning to use MYSQL-Workbench for inserting data into tables

My Problem::

  • I have two columns one for Sl_no and one for Name
  • Sl_no is the primary key which has auto increment checked as shown in snapshot-1
  • If you look at Snapshot-2 auto_increment is not automatically incremented when i keep adding the values
  • should i need to enable any option for this ?
  • Because Using the IDE should automatically add values(Since Sl_NO has autoincrement enabled) but it is not doing so
  • I have to manually add it one after another

Snapshot-1

enter image description here

Snapshot-2

enter image description here

How can i resolve this ?

{EDIT}

  1. I am using Windows-7 OS
  2. As you can see i am clicking the marked area in the pic to apply changes, but nothing is happening.
  3. Should i need to enable any settings

enter image description here

like image 834
Devrath Avatar asked Feb 15 '23 01:02

Devrath


1 Answers

UPDATE: It wasn't apparent right away that you're doing this from model and not directly in your db table.

To create your schema from model you need to do Forward Engineering and in the dialog choose Generate INSERT Statements for Tables.

Then go to the object browser in your MySQL connection, not your model. Fire select statement in query window or choose from context menu Select Rows - LIMIT 1000 and you'll see that your sl_no column is populated as expected.

BTW both mac and windows interfaces are identical.

Original answer: You forgot to commit your changes by clicking Apply

enter image description here

And after reviewing the change script click Apply again.

enter image description here

After that you'll see your auto_increment column values populated

enter image description here

like image 107
peterm Avatar answered Feb 17 '23 02:02

peterm