mysql query browser edit button disabled - mysql

Has anyone had this problem? I deleted a column in the table editor and then went back to MySql Query Browser but the edit button was disabled. Can't seem to figure it out and I hate MySql's forum format so i decided to ask here. Any help is greatly appreciated!

Ahh i think i found out why...
I deleted the primary key..
http://forums.mysql.com/read.php?108,15476,82111

I had this problem, although I had a primary key in the table. It took me quite a while to figure out that the problem was the name of the table! It was "joinclub_requests". Apparently, if the name starts with "join", the Query Browser thinks its a join table and disables the edit button.

Related

SQL query that is bugged in a way I don't understand

I know the title is weird, but I am on that same bug for HOURS.
I have this query
UPDATE tournaments SET password_req_count = password_req_count + 1 WHERE id = 20;
(You can replace 20 by anything, it really does not matter)
This query modifies a timestamp field called start_timestamp by ALWAYS setting it the computers current hour.
And this query is perfectly fine, there's no bug with this :
UPDATE tournaments SET password_req_count = 0 WHERE id = 20;
This was happening in the PHP code until I removed that one query, then it stopped. Then I decided to try it by directly executing the query myself, without PHP, and the bug is still here.
password_req_count is an int (I mean, I checked it, the problem isn't here)
This query does not appear in the query history of MySQL (the one you can get by pressing the "UP" key to remake a query quickly...), and this bug doesn't appear locally (it only appears on my server). Note that I exported my local database to the server's one, so everything is exactly the same there and here.
The MySQL server version was 5.5 on my server and 5.7 at home, I thought this was the problem so I updated it, but absolutely nothing changed. I also googled a lot about this, but I found no topic talking about this subject.
I do have query logs, so I am SURE that there is NOTHING that edits the start_timestamp (except this weird bug obviously). It is not supposed to be edited anyway.
Edit : I just edited the field name to password_request_count because password_req_count already exists in another table. But the bug is still here.
RECAP HERE
Edit 2 : Here is a video because apparently the post is not clear enough. Notice that I can't do the UPDATE query again by pressing the "up" touch, and please also notice that start_timestamp gets edited if I increment password_req_count.
http://www.nx-lab.com/bug.mp4
Edit 3 : Apparently this also happens if I edit other fields (such as top_prize)
There could be a couple of things doing this, one is a trigger on the table. This code will show you if there are any...
SHOW TRIGGERS FROM tournaments;
The other thing, which is the correct answer in this case, is an auto update on the datetime column. This causes the date and time in the column to be updated automatically when there is an update to the table.
You can read more about it here:
https://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html
If you want to remove to auto update then an ALTER table is required to remove it from the column, from Timestamp without change on update...
ALTER TABLE leads MODIFY added_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP

MySQL Workbench doesn't show columns when I alter the table

I have the table "giorno",I want to alter it but no columns are showed and I can't even add a new column because the existing columns are not shown either, se the screenshot below:
I also tried to create a new table but it appears the same bug. So I can't add new columns.
How is it possible? Maybe I made a mistake with my settings?
Just in case anyone else runs into this. Just click the arrow on the top right (next to schema).
On the right of your screen i can see two scrollbar arrows. Please try to place your mouse pointer there and resize the window.(Its in the same line with the Column Name,Datatype,PK...)
I think there's a bug. I had the same issue, but it was stopping after a
timestamp(6) / on update CURRENT_TIMESTAMP(6)
field. I had to change it to a straight date(6) field with no on update clause, and the rest of the fields then appeared.
After that, I went back and changed my field back to timestamp(6) / on update CURRENT_TIMESTAMP(6) and the table editor displayed everything correctly.
I found the solution. I have 3 tables and any of them has a primary key. I just changed one key from Primary to Index and now everything is working.
For me restarting the workbench solved the problem!

MySQL Workbench auto increment disabled

I am using Workbench version 6.3.5 Community and this is GUI question only.
When creating a new table auto increment check-box is disabled.
Is it a bug or I need to enable this some how in options?
And how to set start value and step for auto increment in GUI when creating a table?
You need to set auto increment in table
As a work around, when you click the 'Apply' button and are presented with the generated script to review, you can actually edit that script. I ran into the issue you posted as well and just manually added AUTO_INCREMENT to the column definition I needed it applied to.
You can do it this way
Halil Saltik
Just check the AI(Auto Increment) checkbox. No work around, that's why it's a workbench. Life made easy
Make sure the datatype is INT, not character based.
If you are like me, and you are wondering how on earth to get to that primary-key, auto-increment checkbox etc:
Hover over the table name, in my example "persons"
A "spanner like icon" will appear
Click on it and that's it!
I am using MySQL Workbench 8.0 CE(v8.0.19)
The field must be both datatype int and the primary key for the table.

Debbuging SQL query

I have a problem debugging some problem.
I started thread in wordpress.stackexchange.com thinking that I get more wordpress related debugging suggestions but went with totally different way.
You can see topic here: https://wordpress.stackexchange.com/questions/123394/some-ways-to-debug-code
with update: DELETE FROM wp_bp_activity WHERE item_id = 0
My Question is SQL related: Can DELETE statement be triggered from something then DELETE query? for example I rememeber having a bad query which was deleting everything. (but that was everything and not an if statment)
So to extend this question: If I search every query with DELETE FROM will I find it for sure? Can this be written differently? Because for now, I can't find it.
TRUNCATE is also used to DELETE all the records from a table.
You can also have some kind of foreign key cascading, that is triggering the delete in that table. More here.
Addicionally, make sure to search on the database also, on triggers and on stored procedures
One other option is that they were updated to a different value than the one you are looking for.

How to add on delete cascade and on update restrict using phpmyadmin?

I want to add 'On delete cascade and on update restrict' on foreign keys through phpmyadmin user Interface instead of executing query.
I generally use Heidisql control panel for doing these actions. And now I'm having hard time doing the same on phpmyadmin.
Any idea?
In the tab where you define the table structure, you get the list of columns and their properties and underneath that there should be a link "relation view", between "print view", and "propose table structure."
That's where you want to go, but you have to have created the index on both tables already.
Also, you might want to make sure you're using mysql's innoDB storage engine.
Edit : An image is worth 1000 words :
Cimbali's answer worked for me, but things were placed a little differently, so in case you're also looking for the "relation view" link, try looking there:
It should take you there:
Key fact:
1. Both table must be have innodb storage engine.
2. The datatype and length should be same in both table.
3. The field in 2nd table should be created as index.
Hope it will help someone...