gpt4 book ai didi

mysql - 从脚本运行 mySQL 查询

转载 作者:行者123 更新时间:2023-11-29 13:53:25 29 4
gpt4 key购买 nike

在我的数据库课上,老师布置我们使用 Oracle SQL 来设计一个应用程序。因为我对 mySQL 有更多经验,他说我可以使用它。

我想让我的作业看起来尽可能与他的示例相似。他的示例由一个文件 run.sql 组成,如下所示:

@start //this runs start.sql which creates the tables

DESC table_name; //do this for all tables

@insert //this runs insert.sql that creates dummy data

SELECT * FROM table_name; //do this for all tables

@query //this runs query.sql that runs our sample queries

@drop //this kills all the data

有没有办法做类似的事情?

即编写调用外部查询并将所有数据输出到 output.txt 文件的查询的方法?

最佳答案

使用“source”输入*.sql文件

使用“create procedure”生成“drop”函数

使用“进入输出文件'/文件/路径';”在您选择写出。

双重重定向以附加:“进入outfile '>>/file/path';”

关于mysql - 从脚本运行 mySQL 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16311995/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com