Is there a way from /usr/bin/mysql or /usr/bin/mysqlimport to import a sql file but exclude all rows where a specific field doesn't have a specific value?
I want to restore data from backup, but only backup data where the field "origin" has the value "import". So I have a script that first deletes all rows in the live database "where origin = 'import'" and then I want to import from a file all those rows that I have backed up, but not every single row, since there are other origins in the backup.
Am I making myself clear? Any ideas?
Two thoughts:
Prepare the sqlfile by adding a where clause to each statement. Should be relatively easy with your favorite scripting language.
Import to a temp "schema" and for each table:
insert into realtable select * from temptable where origin = 'import';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.