I am trying to load a small sample of records from a large database into a test database.
How do you tell mysqldump to only give you n records out of 8 million?
Thanks
I am trying to load a small sample of records from a large database into a test database.
How do you tell mysqldump to only give you n records out of 8 million?
Thanks
As skaffman says, use the --where option:
mysqldump --opt --where="1 limit 1000000" database
Of course, that would give you the first million rows from every table.
If you want to get n records from a specific table you can do something like this:
mysqldump --opt --where="1 limit 1000000" database table > dump.sql
This will dump the first 1000000 rows from the table named table into the file dump.sql.
mysqldump can be given a SQL query to execute, from which it will take the data for the dump. You can then use the "limit X" clause in your query to restrict the number of rows.