【问题标题】:MYSQL command to execute multiple .sql filesMYSQL命令执行多个.sql文件
【发布时间】:2012-08-09 12:58:01
【问题描述】:

我想编写并执行一个 mysql .sql 文件,该文件将执行多个其他 .sql 文件。我正在寻找类似于 Oracle 的东西:

@script1.sql
@script2.sql
@script3.sql

MYSQL有命令吗?

【问题讨论】:

    标签: mysql sql oracle


    【解决方案1】:

    从 bash 或任何 shell,您可以按如下方式运行

    cat script*.sql | mysql -u root -pYOURPASSWORD  dbname
    

    这将为您的 'dbname' 的 sql 文件执行所有操作

    干杯!!

    【讨论】:

      【解决方案2】:
      source script1.sql;
      source script2.sql;
      ...
      

      【讨论】:

      • 我之前确实尝试过,但没有成功。我收到错误消息:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'source user.sql' at line 1。我有一个 build.sql 文件,我想在运行多个文件的 Eclipse 中执行该文件。您编写的命令是否必须在 mysql 提示符下运行?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-13
      • 1970-01-01
      • 2015-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多