作者:wumu | 来源:互联网 | 2023-02-07 14:48
IusePHPMyAdminforconvenienceinupdatingaremotedatabase.我使用PHPMyAdmin来方便更新远程数据库。Butitdoe
I use PHPMyAdmi
n for convenience in updating a remote database.
我使用PHPMyAdmin来方便更新远程数据库。
But it doesn't show warnings, by default, which recently got me into some embarrassing trouble where I was updating a SET field with string not on its list and not noticing the problem.
但默认情况下,它没有显示警告,最近让我陷入了一些令人尴尬的麻烦,我在更新SET字段时,字符串不在其列表中而没有注意到问题。
I'm using 2.11.9.1 (Dreamhost's default install)
.
我正在使用2.11.9.1(Dreamhost的默认安装)。
On the PHPMyAdmin
wiki it lists "Display warnings" as a feature of version 2.9.0 and even "Display all warnings" as a feature of 2.10.2 -- but how do I actually turn this on? The documentation isn't great.
在PHPMyAdmin wiki上,它将“显示警告”列为版本2.9.0的一个功能,甚至将“显示所有警告”列为2.10.2的一个功能 - 但是如何实际启用此功能?文档不是很好。
4 个解决方案
1
I was just looking for the same thing.
我只是在找同样的事情。
When I ran INSERTs
using the standard phpMyAdmin 'insert' form, rows would get inserted but a red bar would appear stating any warnings. But when I did a bulk insert, no warnings would appear and a green bar appeared instead just saying the number of rows affected (giving you the impression that it had all gone successfully, when in fact it may not have).
当我使用标准的phpMyAdmin'insert'表单运行INSERT时,将插入行,但会出现一个红色条,表示任何警告。但是当我进行批量插入时,不会出现任何警告,并且会出现绿色条,而只是说影响的行数(给您的印象是它已经成功完成,实际上它可能没有)。
I found I had to send the SHOW WARNINGS
command manually. For example, when running this query, I put both statements into the phpMyAdmin SQL box.
我发现我必须手动发送SHOW WARNINGS命令。例如,在运行此查询时,我将两个语句都放入phpMyAdmin SQL框中。
INSERT INTO test2 SELECT * FROM test1;
SHOW WARNINGS;
This gave a list of warnings like the following...
这给出了一系列警告,如下所示......
Level Code Message
Warning 1265 Data truncated for column 'a' at row 1
Warning 1265 Data truncated for column 'a' at row 3
Warning 1265 Data truncated for column 'b' at row 3
Warning 1366 Incorrect integer value: 'x' for column 'b' at row...
Things to note:
注意事项:
- You cannot run the
SHOW WARNINGS
command later, it will appear empty. It must be in the box with your initial query when you click "Go". This is because MySQL only holds the warnings for the last query you ran. Every time you click a link or button phpMyAdmin runs all sorts of other queries on the DB and so your previous warnings get lost.
您以后无法运行SHOW WARNINGS命令,它将显示为空。单击“开始”时,它必须在初始查询的框中。这是因为MySQL只保存您运行的上一个查询的警告。每次单击链接或按钮时,phpMyAdmin都会在数据库上运行各种其他查询,因此您之前的警告会丢失。
phpMyAdmin does NOT support showing multiple results from a custom query. So doing this as one SQL script does NOT work... (as of version 3.4.10.1)
phpMyAdmin不支持显示自定义查询的多个结果。所以这样做就像一个SQL脚本不起作用......(从版本3.4.10.1开始)
INSERT INTO test2 VALUES ('my text', 'something else');
SHOW WARNINGS; # you won't see the warnings from here
INSERT INTO test2 VALUES ('my text', 'something else');
SHOW WARNINGS;
Although the method above will not work in phpMyAdmin, it SHOULD work fine in the MySQL command line client. So use that if you need to.
虽然上面的方法在phpMyAdmin中不起作用,但它应该在MySQL命令行客户端中正常工作。如果需要,请使用它。
If you do have multiple inserts and want to show all warnings, you've got to chain them together as a single INSERT
statement. For example:
如果您确实有多个插入并希望显示所有警告,则必须将它们作为单个INSERT语句链接在一起。例如:
INSERT INTO test2 VALUES
('my text', 'something else'),
('my text', 'something else');
SHOW WARNINGS;