30

I have installed MySQL Workbench and I have the following problem.

I perform this simple select query:

SELECT * FROM spring_security.user;

that returns a list of rows.

So, in the output area, I select a field of a specific row and I try to change its value. But I can't do it.

Seems that is is impossible insert a new value for a specific field of a specific row.

Why? How can I use this tool to change a value?

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
  • 1
    `UPDATE` statement is your friend. `UPDATE SET column = 'value' WHERE id = ?`
    – Lukasz Szozda Oct 16 '15 at 17:34
  • Ok but using TOAD or SQL developer I can also do visually – AndreaNobili Oct 16 '15 at 17:37
  • How would you like to visually update `SELECT * FROM tabA JOIN tabB...`? – Lukasz Szozda Oct 16 '15 at 17:38
  • I don't know anything about your configuration, but you may be connected as a user who doesn't have permissions to Insert/Update. You should be able to double-click a field, change the value and hit `Apply` in the bottom-right. Adding to @lad2025's comment, all queries become read-only if you add a `JOIN` to it. – Tim Lewis Oct 16 '15 at 17:38
  • @TimLewis strange...I am using root... – AndreaNobili Oct 16 '15 at 17:43
  • 4
    Hmm.. So that *shouldn't* be the issue. Does your result pane says `! Read Only` in the bottom right corner? – Tim Lewis Oct 16 '15 at 17:45
  • 1
    Oh, just another thought. Are you trying to update a table that doesn't have an auto-incrementing primary key? "Unsafe" inserts/updates (ie those that try to insert/update *without* the use of a primary key) are turned off by default in MySQL Workbench. Trying to run something like `UPDATE users SET first_name = "Foo" WHERE last_name = "bar";` would fail by default. – Tim Lewis Oct 16 '15 at 17:53

4 Answers4

36

You can do easy with MySql Workbench this way :

in menu database simply connect

then select the database you need and then the table.

Positioning the mouse over the table name in table schemas explore and so you can see on the rightside a table icon.

Selecting/clicking this icon you can see the date in tabular form (like Toad).

With this tabular form you can edit and apply the change

Applying the change MySql Workbench show you the sql code and ask for confirm (the apply button is on the lower right corner of the table)

ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
17

Leif Neland's comment on @scaisEdge's answer is the real solution (as indicated by the huge comment-upvote count), so here it is as an answer, to increase its visibility:

Given that:

  • your query selects from just one table (no join)
  • the table has a unique primary key
  • your DB user has permission to UPDATE

Then, in the Result Grid, you can edit a field by one of the following:

  • Click a field once to select it (the cursor changes into text cursor), and click a second time to start editing in-place in the Result Grid, or
  • Right click on a the field and select the "Open Value in Editor" option

After editing the value, you need to apply it:

The [apply] and [revert] buttons are at the lower right corner of the table.

Leif Neland

As shown here: enter image description here

Daryn
  • 4,791
  • 4
  • 39
  • 52
4

Also, you can execute next script:

UPDATE table SET cell='new_value' WHERE whatever='somevalue'

landonandrey
  • 1,271
  • 1
  • 16
  • 26
0

This answer may be too late, but in case anyone needs it, MAKE SURE THE TABLE HAS A PK (Primary KEY) if it has a PK you will able to edit it in MySQL Workbanch

Yelmox
  • 31
  • 1
  • 7