我想用一个存储过程导入数据.可惜语法都是错的。
DELIMITER $$
CREATE PROCEDURE xx()
BEGIN
source c:/x1.sql                
END $$
DELIMITER ;ERROR 1064 (42000): 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 'c:/x1.sql END' at line 3请各位大哥讲解 ,怎样在存储过程里面使用source....

解决方案 »

  1.   

    source 不是SQL命令,用LOAD DATA INFILE
    OR
    用MYSQLDUMP导入
      

  2.   


     mysqldump 好像是到出的
     mysqldump 可以导入吗?
      

  3.   

     在问个比较S B点的问题。。
     你是怎么知道source 不是sql的命令。
     我在mysql client里面可以运行为什么不是sql命令。。
     如果说它是第三方工具,那貌似mysqldump也是第三方的吧
     那为什么mysqldump可以呢?
     别告诉我mysql sql命令大全里面没有这个命令,所以他不是sql命令。。- -! 以上有误解的地方,希望各位大哥明示。。
      

  4.   

    source 不是SQL语句,是MYSQL命令工具中的一个命令。无法在存储过程中实现。下面都是MYSQL命令行工具中的命令
    mysql> helpFor information about MySQL products and services, visit:
       http://www.mysql.com/
    For developer information, including the MySQL Reference Manual, visit:
       http://dev.mysql.com/
    To buy MySQL Enterprise support, training, or other products, visit:
       https://shop.mysql.com/List of all MySQL commands:
    Note that all text commands must be first on line and end with ';'
    ?         (\?) Synonym for `help'.
    clear     (\c) Clear the current input statement.
    connect   (\r) Reconnect to the server. Optional arguments are db and host.
    delimiter (\d) Set statement delimiter.
    ego       (\G) Send command to mysql server, display result vertically.
    exit      (\q) Exit mysql. Same as quit.
    go        (\g) Send command to mysql server.
    help      (\h) Display this help.
    notee     (\t) Don't write into outfile.
    print     (\p) Print current command.
    prompt    (\R) Change your mysql prompt.
    quit      (\q) Quit mysql.
    rehash    (\#) Rebuild completion hash.
    source    (\.) Execute an SQL script file. Takes a file name as an argument.
    status    (\s) Get status information from the server.
    tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
    use       (\u) Use another database. Takes database name as argument.
    charset   (\C) Switch to another charset. Might be needed for processing binlog
    with multi-byte charsets.
    warnings  (\W) Show warnings after every statement.
    nowarning (\w) Don't show warnings after every statement.For server side help, type 'help contents'mysql>
      

  5.   

      我在mysql client里面可以运行为什么不是sql命令。。mysql client 只是把你输入的命令分析处理,一些SQL语句会提交个数据库来处理!
      

  6.   

    先读《数据库系统概论(第四版)》 王珊 萨师煊   高等教育出版社 (掌握基础知识和概念) 然后再粗略浏览一遍MYSQL的官方手册。(方便以后查找,避免类似于考试的时候,给你本政治书也不知道答案在第几章,第几页)MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
      

  7.   

    SOURCE是MYSQL客户端工具提供的一个接口,用来执行.SQL命令,而不是标准SQL命令,所以无法在存储过程中当标准SQL来执行了。你把下面的代码复制粘贴到一个BAT文件里,运行,就可以一次导入1,2,3个SQL脚本。@echo off
    echo.
    echo 开始替换存储过程"D:\mysql6\bin\mysql"  -uroot -p123 test<c:\1.sql
    "D:\mysql6\bin\mysql"  -uroot -p123 test<c:\2.sql
    "D:\mysql6\bin\mysql"  -uroot -p123 test<c:\3.sqlecho.echo 存储过程替换完成echo.
    echo.pausetest是你要脚本处理的数据库。
    D:\mysql6\bin是MYSQL的安装路径。