It's a long sentence, anyone knows?
Asked
Active
Viewed 259 times
2 Answers
3
To create the dump
:
mysqldump --user [username] --password=[password] --no-create-info [database name] [table name] > /tmp/dump.sql
To restore:
mysql --u [username] --password=[password] [database name] [table name] < /tmp/dump.sql

codaddict
- 445,704
- 82
- 492
- 529
-
The only obvious caveat in the restore is foreign key relationships. But i don't see any solution to that. – extraneon Apr 25 '10 at 08:48
-
`[table name]` is not necessary in the restore part. – user198729 Apr 25 '10 at 08:54
1
Some thing like this:
SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_tablename
WHERE 1=0
I'm not sure this works with My SQL but you get the idea.
This DOES NOT duplicate PK, FK, Indexes, Stored Procedures, or anything else. Just the columns and data types.
D'oh
I must have misunderstood your question. It is almost 3am way past bedtime.
Ok so there is probably a better way to do this, but this would get the job done.
SELECT CONCAT('INSERT INTO (COL1, COL2) VALUES (',COL1,COL2,');');
You will need to add ' for some data types so.
SELECT CONCAT('INSERT INTO (COL1, COL2) VALUES (',COL1,''' ''',COL2,');');
The take the output and run on the remote db.

NitroxDM
- 5,039
- 10
- 44
- 56
-
The new_table is on another machine.So I think I have to do it in 2 steps. – user198729 Apr 25 '10 at 08:42