MySQL Forums
Forum List  »  General

Copy Subset of Table to another Table
Posted by: John Noble
Date: October 29, 2024 03:52AM

Hi folks,

I have a batch file that copies a table from one database to another...

"\\mysqlPath\mysqldump.exe" -h 10.1.1.1 -uroot -ppassword dbname customers > \\sqlPath\customers.sql
"\\mysqlPath\bin\mysql.exe" -uroot -ppassword -h localhost dbname2 < \\sqlPath\customers.sql

It all works fine.

But what I really want is a subset of the source table to be copied across.
Instead of all Customers, I would like customers with a given country ID. e.g SELECT * FROM customers WHERE countryID = "DE". Can this be done?

I tried to create a VIEW insted of a table...

"\\mysqlPath\mysqldump.exe" -h 10.1.1.1 -uroot -ppassword dbname customersgermanyVIEW > \\sqlPath\customers.sql
"\\mysqlPath\bin\mysql.exe" -uroot -ppassword -h localhost dbname2 < \\sqlPath\customers.sql

But it just creates a VIEW with the same name on the destination which is of no use.

Is there any around this ?

J

Options: ReplyQuote


Subject
Written By
Posted
Copy Subset of Table to another Table
October 29, 2024 03:52AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.