[英]MYSQL DELETE and Roll back
I have a problem. 我有个问题。
Past month I have a user query: 上个月,我有一个用户查询:
DELETE
FROM table_name
WHERE name = 'test';
it deletes approx 100 rows which is working fine. 它会删除大约100行,这可以正常工作。
But now I need that the delete rows that were deleted are rolled back? 但是现在我需要回滚已删除的删除行吗? Is there is any procedure to get all my rows back?
是否有任何程序可以将我所有的行取回?
I am using mysql. 我正在使用mysql。
Thanks in advance 提前致谢
No. The rows are gone. 不行。 MySQL has no built-in revision control constructs.
MySQL没有内置的修订控制构造。 If you are worried about this being a common occurrence, make sure to back up your database before you run these kinds of queries (look into
mysqldump
) 如果您担心这种情况很常见,请确保在运行这些查询之前备份数据库(查看
mysqldump
)
Have you checked in the mysqlbinlog? 您是否已签入mysqlbinlog? There could still be something of value in there.
那里可能仍然有价值。
And I'm sure you'd have a backup that you could restore from? 而且我确定您将拥有可以还原的备份? :)
:)
Currently you are lost, but in the future to prevent this: 目前您迷路了,但将来会避免这种情况:
From php.net using PDO 从php.net使用PDO
http://php.net/manual/en/pdo.begintransaction.php http://php.net/manual/en/pdo.begintransaction.php
<?php
/* Begin a transaction, turning off autocommit */
$dbh->beginTransaction();
/* Change the database schema and data */
$sth = $dbh->exec("DROP TABLE fruit");
$sth = $dbh->exec("UPDATE dessert
SET name = 'hamburger'");
/* Recognize mistake and roll back changes */
$dbh->rollBack();
/* Database connection is now back in autocommit mode */
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.