How do I delete only the results of one table in a database in MySQL and replicate to another remote empty table with the same structure?
2 answers
Something like that:
SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_tablename
WHERE 1=0
I'm not sure if this works with My SQL, but you get the idea.
It does NOT duplicate PCs, FKs, indexes, stored procedures, or whatever. Just columns and data types.
D'o
I must have misunderstood your question. It's almost 3 hours before bed.
So, there might be a better way to do it, but this will get the job done.
SELECT CONCAT('INSERT INTO (COL1, COL2) VALUES (',COL1,COL2,');');
You will need to add 'for some data types.
SELECT CONCAT('INSERT INTO (COL1, COL2) VALUES (',COL1,''' ''',COL2,');');
Take the output and run on the remote db.
+1
a source to share