I've noticed some quirks with MySQL Workbench when I try to update table data directly through the MSW table editor. One example is that I have a table with a BIT column. If I change the value from 0 to 1 or from 1 to 0 and then click the Apply button, MSW opens a dialog with the Update SQL to be executed. When I click the OK button to execute the auto-generated SQL, MSW reports that the update SQL statement is invalid.
When I take a look at the generated SQL, the problem is that MySQL wraps the updated BIT value in quotes. So obviously that's a type mismatch. Any idea why I might be experiencing this quirk in MSW? This seems like a pretty straightforward use case for a mature technology?
Related
I am the superuser of a particular database schema. Therefore I have all privileges on the tables in this schema, including ALTER DELETE UPDATE and INSERT.
I am administrating this database using the GUI MySQL Workbench 6.3. I used to select rows and to obtain a read-only result grid, which was convenient because it prevented me from accidentally editing data in my table.
This was indicated by a 'read only' flag in the bottom right corner of the result grid (see below).
However, I did not change anything in the structure of the table, and now when I select rows I am able to edit data and the 'read only' flag has disappeared.
I find it a bit unsecure because it would mean I could accidentally edit data in the table by mistyping.
How could I revert to a read-only result display?
The rules that allow editing a result set are very strict. The select query must be a plain one - no aggregate functions, no joins, no unions. There must be a primary key which is used to address the records to be changed.
Update: it wasn't necessary to worry about accidentally editing records in the table while not being in read-only mode.
Indeed, if you change a record in the table (in the screenshot below, I changed a year from 2010 to 2020), for this change to be actually committed in the database, you would need to click the "apply" button in the bottom right corner.
Moreover, upon closing the tab, you are asked whether or not you want to save changes. Consequently, if you accidentally edited a record, you just have to click "Don't save" upon closing the tab.
I'm a java dev who uses Mysql Workbench as a database client and IntelliJ IDEA as an IDE. Every day I do SQL queries to the database from 5 up to 50 times a day.
Is there a convenient way to save and re-run frequently used queries in Mysql Workbench/IntelliJ IDEA so that I can:
avoid typing a full query which has already been used again
smoothly access a list of queries I've already used (e.g by auto-completion)
If there is no way to do it using Mysql Workbench / IDEA, could you please advise any good tools providing this functionality?
Thanks!
Create Stored Procedures, one per query (or sequence of queries). Give them short names (to avoid needing auto-completion).
For example, to find out how many rows in table foo (SELECT COUNT(*) FROM foo;).
One-time setup:
DELIMITER //
CREATE PROCEDURE foo_ct
BEGIN;
SELECT COUNT(*) FROM foo;
END //
DELIMITER ;
Usage:
CALL foo_ct();
You can pass arguments in in order to make minor variations. Passing in a table name is somewhat complex, but numbers of dates, etc, are practical and probably easy.
If you have installed SQLyog for your mysql then you can use Favorites menu option in which you can save your query and in one click it will automatically writes the saved query on Query Editor.
The previous answers are correct - depending on the version of the Query Browser they are either called Favorites or Snippets - the problem being you can't create sub-folders to group them. And keeping tabs open is an option - but sometimes the browser 'dies' - and you're back to ground 0. So the obvious solution I came up with - create a database table! I have a few 'metadata' fields for descriptions - the project a query is associated to; problem the query solves; and the actual query.
You could keep your query library in an SQL file and load that when WB opens (it's automatically opened when you restart WB and that file was open on last close). When you want to run a specific query place the caret in it's text and press Ctrl+Enter (Cmd+Enter on Mac) to run only this query. The organization of that SQL file is totally up to you. You have more freedom than any "favorites" solution can give you. You can even have more than one file with grouped statements.
Additionally, MySQL Workbench has a query history (see the Output Tab), which is saved to disk, so you can return to a query even month's after you wrote it.
When I use MySQL workbench and get a huge dataset, i find it annoying that if I accidentally click on a row, workbench tries to order the data by that row - generally taking several minutes to complete.
I'm of the opinion that if I wanted a dataset ordered a particular way, I would have used an order-by clause.
Is there any way to disable the behavior of ordering a dataset by clicking on a particular column?
Unfortunately I think you're out of luck in this regard, unless of course you download the source code for MySQL Workbench and change the way the UI behaves and add in an option to disable column ordering on click.
Source is available here. (Change the 'select platform' drop down to 'Source Code')
I have a MySQL trigger that I would like to be modified. The only changes are in the trigger body.
Will updating the ACTION_STATEMENT Column in INFORMATION_SCHEMA.TRIGGERS suffice? Is this the right way to update a trigger? Specifically, I am looking for any problems that might arise by doing this.
That won't work.
You need to drop the trigger and recreate it.
http://dev.mysql.com/doc/refman/5.1/en/create-trigger.html
Download dbForge express (is free as in Beer).
Connect with that and edit the trigger.
Download page
http://www.devart.com/dbforge/mysql/studio/download.html
Direct link
https://www.devart.com/dbforge/mysql/studio/dbforgemysql80exp.exe
Don't muck about in the information_schema.
Oh and don't use MySQL workbench 5.2 I've had that one eat my work twice (..gone..) never again.
No I don't have shares, just a happy dbForge user
The ACTION_STATEMENT column contains the statement to be executed when the trigger is invoked. This is the same as the text displayed in the Statement column of the output from SHOW TRIGGERS. Note that this text uses UTF-8 encoding.
MYSQL TRIGGERS SCHEMA TABLE
You're right, if you edit the ACTION_STATEMENT field, you modify the SQL action.
I have a very weird situation here. During development I discovered that one of my tables got more and more empty rows (the Id field is auto-incremented and was set). No insert statement was run from my code.
I use SQL Manager 2010 Lite for MySQL to inspect the data, and it turns out that when I Execute the select statement from there, the empty row gets added.
Has anyone else experienced this? All i do is right click the table, select 'Script to NEW SQL Editor' and Select. When I press Execute, the row gets added.
Not really an answer - I'm using phpmyadmin myself - but you could try setting one of the columns to not null? Just to see what happens, and what kind of error message you get? And you could also check to see if there are any stored procedures that could cause this.
Normally I would post this in a comment, but I don't have enough rep to do that yet, sorry...