[英]How can I copy one column (field) from one table to an empty column (field) of another table both of which are part of same database using MySQL?
[英]How do I dump only results of one table in a database in MySQL and replicate to another remote empty table with the same structure?
這句話很長,有人知道嗎?
創建dump
:
mysqldump --user [username] --password=[password] --no-create-info [database name] [table name] > /tmp/dump.sql
恢復:
mysql --u [username] --password=[password] [database name] [table name] < /tmp/dump.sql
像這樣的東西:
SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_tablename
WHERE 1=0
我不確定這是否適用於My SQL,但是您可以理解。
這不重復PK,FK,索引,存儲過程或其他任何內容。 只是列和數據類型。
D'哦
我一定誤會了你的問題。 睡前將近凌晨3點。
好的,也許有更好的方法可以做到這一點,但這可以完成工作。
SELECT CONCAT('INSERT INTO (COL1, COL2) VALUES (',COL1,COL2,');');
對於某些數據類型,您將需要添加'。
SELECT CONCAT('INSERT INTO (COL1, COL2) VALUES (',COL1,''' ''',COL2,');');
取得輸出並在遠程數據庫上運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.