MySQL - 如何执行大型查询?
在 Workbench 中,我将整个数据库设计导出到一系列 CREATE TABLE 语句中。由于大小查询(有超过 50 个表),我遇到了错误。我可以做些什么来让 MySQL 接受大型查询吗?
另外,我有一个大 SQL 来插入虚拟数据。我想我也会遇到同样的问题。
SQL 查询位于一个文件中。我想以编程方式打开文件,获取查询,然后执行它。我正在使用 PHP/CodeIgniter。
In Workbench, I export my entire DB design into a series of CREATE TABLE statements. I was running into errors due to the size query (there are over 50 tables). Is there something I can do to make MySQL accept large queries?
Also, I have a big SQL to insert dummy data. I assume I'll run into the same problem as well.
The SQL queries are in a file. I want to programatically open the file, grab the query, then execute it. I'm using PHP/CodeIgniter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 mysql 命令行客户端并从文件或 STDIN 读取它们来运行多个查询。这通常可以正常工作,不会出现任何问题,而且我知道很多系统都依赖于此。
请参阅4.5.1。
mysql
— MySQL 命令行工具文档和非交互式使用。You can run multiple queries by using the mysql commandline client and reading them from file or STDIN. That normally works without any issues and I know a lot of systems that rely on this.
Please see 4.5.1.
mysql
— The MySQL Command-Line ToolDocs and non-interactive use.我之前在共享主机和性能不佳的本地计算机上遇到过类似的问题。
我过去曾使用 BigDump 来错开导入。
如果有人给了您转储文件,则分解导入并不总是一个选择,以不同方式导出它也不是一个选择,因为您可能无权访问原始数据库。
I have had issues like this before on shared hosting and on poorly performing local machines.
I have used BigDump in the past to stagger the import.
Breaking up the import isn't always an option if someone has given you a dump file, exporting it differently isn't an option as you may not have access to the original DB.