Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否将我在sql上的所有工作保存在一个文件中?_Sql_Bash_File - Fatal编程技术网

是否将我在sql上的所有工作保存在一个文件中?

是否将我在sql上的所有工作保存在一个文件中?,sql,bash,file,Sql,Bash,File,实际上,我正在linux终端上开发Mysql 我需要一种方法或命令来将我编写的所有查询及其输出保存到一个文件中 那么,编写每个查询并将其重定向到文件是非常困难和无用的 如果有任何bash脚本或命令,它将非常有用。我刚刚发现有一个sql命令可以将查询和输出保存到文件中 mysql> tee filename ; 例如: mysql> tee tmp/output.out; ..logging to file 'tmp/output.out' 现在:每个查询及其输出都将保存在outp

实际上,我正在linux终端上开发Mysql

我需要一种方法或命令来将我编写的所有查询及其输出保存到一个文件中

那么,编写每个查询并将其重定向到文件是非常困难和无用的


如果有任何bash脚本或命令,它将非常有用。

我刚刚发现有一个sql命令可以将查询和输出保存到文件中

mysql> tee filename ;
例如:

mysql> tee tmp/output.out;
..logging to file 'tmp/output.out'
现在:每个查询及其输出都将保存在output.out文件中


注意:“记得写不带引号的文件名”

我刚刚发现有一个sql命令可以将查询和输出保存到文件中

mysql> tee filename ;
例如:

mysql> tee tmp/output.out;
..logging to file 'tmp/output.out'
现在:每个查询及其输出都将保存在output.out文件中


注意:“记住写文件名时不要加引号”

是的,tee命令可用于此目的

在登录mysql时,您可以像

mysql-u username-pPassword | tee-a outputfilename


您的整个会话将存储在文件中

是的,tee命令可用于此目的

在登录mysql时,您可以像

mysql-u username-pPassword | tee-a outputfilename


您的整个会话将存储在文件中

这有点高级,但我刚刚开始使用OrgBabel,它对SQL非常有用

在您的
init.el
中设置org babel:

(org-babel-do-load-languages 'org-babel-load-languages
                             '((sql . t)))
(setq org-confirm-babel-evaluate nil
      org-src-fontify-natively t
      org-src-tab-acts-natively t)
并创建一个组织模式缓冲区。如果需要,您可以在
*scratch*
中运行
M-x组织模式

然后编写SQL:

#+BEGIN_SRC sql :engine "mysql" :dbhost "db.example.com" :dbuser "jqhacker" :dbpassword "passw0rd" :database "the_db"
show tables
select * from the_table limit 10
#+END_SRC
通过将光标放在SQL块中并键入
C-C-C
来计算它。结果显示在缓冲区中。您可以编写任意数量的源代码块,并按任意顺序计算它们


OrgBabel还有很多功能:

这有点高级,但我刚刚开始使用OrgBabel,它对SQL非常有用

在您的
init.el
中设置org babel:

(org-babel-do-load-languages 'org-babel-load-languages
                             '((sql . t)))
(setq org-confirm-babel-evaluate nil
      org-src-fontify-natively t
      org-src-tab-acts-natively t)
并创建一个组织模式缓冲区。如果需要,您可以在
*scratch*
中运行
M-x组织模式

然后编写SQL:

#+BEGIN_SRC sql :engine "mysql" :dbhost "db.example.com" :dbuser "jqhacker" :dbpassword "passw0rd" :database "the_db"
show tables
select * from the_table limit 10
#+END_SRC
通过将光标放在SQL块中并键入
C-C-C
来计算它。结果显示在缓冲区中。您可以编写任意数量的源代码块,并按任意顺序计算它们

巴别塔还有很多: