2011-01-12 101 views
2

mysqldump(或其他一些命令)是否有選項來轉儲最近更新的行?我一直無法在文檔中找到任何關於此的信息。謝謝。最近記錄的mysqldump

+0

在你的情況下* recent *的定義是什麼? – alex 2011-01-12 00:55:07

回答

6

你可以使用--where選項給mysqldump一個where子句。所以,如果你有一個名爲您的表「修改時間」欄,並要在在過去2小時修改的所有行,你可以做這樣的事情:

mysqldump my_schema my_table --where="modified > now() - interval 2 hour" 
1

使用 「INTO OUTFILE」 語法:

LOAD DATA INFILE '/tmp/result.txt' INTO table 
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 
LINES TERMINATED BY '\n' 

文檔關於MySQL的網站:

http://dev.mysql.com/doc/refman/5.5/en/select.html

SELECT * FROM table INTO OUTFILE '/tmp/result.txt' 
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 
LINES TERMINATED BY '\n' 
WHERE timestamp > ? 

然後,您可以通過使用稍後如果有必要導入此

http://dev.mysql.com/doc/refman/5.5/en/load-data.html

0

從mysqldump的手冊頁:

--where = 'where_condition',-w'where_condition'

 Dump only rows selected by the given WHERE condition. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your 
     command interpreter. 

     Examples: 

      --where="user=´jimf´" 
      -w"userid>1" 
      -w"userid<1" 
0

爲所需查詢定義一個視圖。然後在視圖上使用mysqldump。