从MySQL数据库表生成SQL脚本 [英] Generating SQL script from MySQL database table

查看:302
本文介绍了从MySQL数据库表生成SQL脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何应用程序可以读取MySQL数据库表并生成INSERT语句的SQL脚本(以便我可以将表从一个数据库复制到另一个数据库)?或在表1和表2相同的情况下,如何将内容从db1.table1传输到db2.table2.

Is there any application that will read a MySQL database table and generate a SQL script of INSERT statements (so that I can copy tables from one db to another db)? OR how can I transfer content from db1.table1 to db2.table2 where table1 and table2 is same.

谢谢.

推荐答案

mysqldump [options] db_name [tbl_name ...]

将生成脚本文件,包括创建和插入所选表所需的脚本.要导入转储,您只需执行以下操作:

Will generate the script file including the create and inserts necessary for the tables selected. To import the dump you can simply do:

mysql -u <user> -p dbname < mys.dmp

这篇关于从MySQL数据库表生成SQL脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆