4

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

Devrath
  • 42,072
  • 54
  • 195
  • 297
  • http://stackoverflow.com/questions/4829400/adding-id-auto-increment-after-table-exist – Nagaraj S Jan 21 '14 at 04:16
  • Watch out where you do your inserts! In a model the data you enter is stored with that model and when you forward engineer that those records are automatically inserted in your table (think of it as test data for your model incarnation). For real db work use the SQL IDE instead and edit tables and their data from there. – Mike Lischke Jan 21 '14 at 13:44

1 Answers1

8

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

peterm
  • 91,357
  • 15
  • 148
  • 157
  • You're doing it from model. That's why you're not seeing any changes. Do `Forward Engineering` and go to the db table (not model) and see your data. See updated answer. – peterm Jan 21 '14 at 05:39
  • What is forward engineering ? .... I am beginner... can u give me steps to do it ! – Devrath Jan 21 '14 at 05:46
  • 2
    FE is a process of creating an actual database from your model. Read [this](http://dev.mysql.com/doc/workbench/en/wb-forward-engineering.html). To do FE go to menu `Database->Forward Engineer...` – peterm Jan 21 '14 at 06:12