Unable to edit or delete fields using phpmyadmin - mysql

I have installed phpMyadmin 4.5.0.2 on Mac book Pro. I am not able to delete rows from my table using "Delete" button nor edit values by double clicking on them. The SQL generated to do this not correct where in it is omitting where clause like below
DELETE FROM Dimn_Observation WHERE LIMIT 1
If I manually type SQL statements it executes Ok. but I am not able to select few rows directly and neither modify or delete rows.
How do I solve this issue.

Related

Remove repeated lines from a text file in order for phpMyAdmin to successfully insert SQL statements into database

I have a large text file full of INSERT SQL statements that I want to insert into a phpMyAdmin database. The problem I am having is that many of these INSERT statements within this file are identical, resulting in “Duplicate Key” error occuring.
Is there a way to make phpMyAdmin ignore the repeated SQL statements? I have tried running the file through a .vbs script that removes duplicate lines but it failed to deliver.
Logic that I am thinking of so far is the following:
Run the file through a script that removes duplicate lines.
Find a solution in which phpMyAdmin ignores repeated lines.
Has anyone got any other ideas or suggestions on how I could solve this problem?
The easy way is by using INSERT IGNORE statement, but you will not know which record is duplicate.
another way, by create new table like 'table2' with no primary key or unique key, insert all the data into it, then INSERT IGNORE to your main table before, and compare which row are duplicate. Or maybe you can use the COUNT() function to get the duplicate row by.

Time of delete and insert action on table in MySQL database

In SQL is there any way to find the last time a table had an insert and delete statement performed on it? I tried
select update_time from information.schema.tables where table_num="tablename";
but that did not work. I am also trying to look at deletions and insertions specifically. I am also working in MySQL Workbench.

UPDATE my_table doesn't work correctly

I'm using the following query to replace old link with a new one:
UPDATE my_table SET file = 'link' WHERE my_table.file ='old_link';
In my tests I can't duplicate that and I'm not sure what's wrong with that query, but apparently sometimes it leaves the old entry and inserts a new one instead of updating!
mysql ver:
5.6.12-56 Percona Server, table type: innodb
The query looks fine to me. UPDATE should never create new rows, only modify existing rows. The problem is probably in another part of the code.
Although an UPDATE won't fire an insert in its own, there could exist triggers in the database that would fire an INSERT whenever a record gets updated.
Here are some links that you should check:
CREATE TRIGGER Syntax
Trigger Syntax and Examples

SELECT * FROM `table` does not return all columns in phpMyAdmin

When I execute SELECT * FROM table, the returned rowset does not contain all of the columns in the table. It does not contain the columns that were recently added. Though, the structure tab in phpMyAdmin shows the new columns. And if I query directly like SELECT new_column_name FROM table, the column values also do appear.
This problem is present both if I query the table via PHP or phpMyAdmin.
Interesting enough, if I run SELECT *, new_column_name FROM table, the new_column_name values are duplicated.
What might the reason for such weird behaviour, and how do I restore the default behaviour showing all columns using *?
UPDATE:
I have flushed the table cache and I have restarted the mysql server, but nothing changes.
UPDATE:
Storage engine is InnoDB
UPDATE:
Before adding new columns, I drag-and-dropped a column header to another place to switch the columns' places. But after adding the columns, I clicked restore column order, so it shouldn't have had any influence...
UPDATE:
After checking what is returned if I run the query via command-line, I now see that the problem is actually only with phpMyAdmin (the command line returns the new columns among others). Double-checking what I was doing in PHP showed that I was explicitly selecting specific columns. So, now the problem persists only in phpMyAdmin. What might be wrong with it?
Had this problem just now.
Fixed it by changing the Storage Engines from InnoDB to MyISAM, then back to InnoDB again.

Is it possible to edit the query result in workbench?

I need to delete some records that comes out of the query result. But the query result is marked as Read Only. even when I query the primary key. The problem is my DB is so large (not much, 1.5 million record) that I can not right click on the table and choose Edit table data as I get the error no. 2008: mysql client ran out of memory which I could not solve (though, my pc has 8 GB RAM). My DB is loaded in the localhost so the client is the server. Please, help.
MySQL Workbench is by default set into secure mode (they call it "Safe updates" mode) meaning that one cannot update or delete rows within SQL editor until WHERE clause with (primary) key or LIMIT parameter is not explicitly defined:
So the query:
DELETE FROM table WHERE name='xyz'
will not work (will not really delete rows) until you define WHERE with PK:
DELETE FROM table WHERE id=100
or
DELETE FROM table WHERE name='xyz' LIMIT 1
To disable secure mode in Workbench go into Edit->Preferences->SQL Editor tab and uncheck "Safe updates" checkbox. But be careful then! :-)
To edit a big table:
You can right click the "Send to SQL Editor -> SELECT All Statement".
Then before running, this, add a LIMIT 100 in that SELECT or a WHERE condition to filter the rows returned.
You can also go to "Preferences -> SQL Editor" and mark the "Limit Rows" checkbox. If you set it to, say 1000, then the "Edit Table" command will fetch the first 1000 rows. You can then move to the next "page" by clicking on the "Fetch next frame of records from the data source" button.
Your other question:
It's not always possible to edit a result set. If it involves GROUP BY or data from more than one tables, then the result set may be Read-only. In that case, you could write a DELETE or UPDATE statement to do the deletion or updates for you.