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

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!

Related

How can I change column order through mysql workbench?

I know how to reorder column order through query,
How do I reorder columns in MySQL Query Editor?,
I just want to know is there any other (simpler) way to do this directly through MySQL workbench.
Right-click the column and choose Move Up or Move Down. Dragging does not work in MySQL Workbench 6.3.
P.Salmon commented with a link that has more detail.
Open Alter Table
Just move column with your mouse to the position you want (Do not select it before this action)
First of all you should get column definition by using show create Table then I think Modify should work
ALTER TABLE yourTableName MODIFY bar bartype AFTER baz;
Hope it will help
As the previous answers point out, we need open Alter Table first. On workbench 8.0, right click table, then click 'Alter table'
Image to show how to open Alter Table on Workbench 8.0
The SQL I got from moving a column is as follows with "CHANGE COLUMN" keywords.
ALTER TABLE `your_database`.`your_table`
CHANGE COLUMN `column_a` `column_a` VARCHAR(16) NULL DEFAULT NULL COMMENT 'this is comment' AFTER `colum_b`;

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 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.

"Table already exists" when changing PK autoincrement in MySQL

I am quite new to MySQL and I have encountered a problem that I find quite puzzling. If I create a table with MySQL Workbench, when I set the PK I can choose it to auto-increment or not, as should be. However, if I change my mind later on, once the table has been created, I cannot alter the auto-increment flag any longer, as MySQL tells me that the "table already exists". That happens even if the table is empty.
The auto-generated SQL is as follows:
ALTER TABLE tablename
CHANGE COLUMN `ID` `ID` INT(11) NOT NULL AUTO_INCREMENT ;
and it fails with the error stated above. I have tried changing the algorithm and lock type, to no avail.
This does not happens in T-SQL or Oracle, for instance, so I fail to see a reason why it should fail in MySQL. Is there any way to fix this without having to drop and re-create the table?
Thanks.
From experience all the GUIs get a bit confused when you start changing primary keys, the number of error messages I've seen from SQL Server...
You don't need to drop the whole table, but it might be easiest to drop and then re-create the offending column.
Also, check out the MySQL dev docs, but I think either ALTER or MODIFY column are the two I'd go for and I'm not sure why the column name is there twice if you're not renaming it.
Ok, I discovered the culprit thanks to dbForge Studio. The same thing happens there, but this time the error is more explicit: I cannot change the auto-increment flag apparently because it is used as a foreign key on another table. I deleted the FK and then I was able to set the auto-increment.
Thank you all who helped me, I have learned some new things thanks to your comments.

mysql query browser edit button disabled

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.