执行SQL脚本以创建表和行 [英] Execute SQL script to create tables and rows

查看:171
本文介绍了执行SQL脚本以创建表和行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库,该数据库是我在终端中使用CREATE DATABASE语句创建的,并且我有一个.sql文件,其中充满了创建表和行的语句.

I have a database that I created using the CREATE DATABASE statement in the terminal and I have a .sql file full of statements creating tables and rows.

我只想知道在我创建的数据库上执行该.sql的命令行是什么?

I just wanted to know what was the command line to execute that .sql on the database I created?

推荐答案

在MySQL交互式客户端中,您可以输入:

In the MySQL interactive client you can type:

source yourfile.sql

或者,您也可以从命令行将数据通过管道传递到mysql中:

Alternatively you can pipe the data into mysql from the command line:

mysql < yourfile.sql

如果文件未指定数据库,则还需要添加:

If the file doesn't specify a database then you will also need to add that:

mysql db_name < yourfile.sql

有关更多详细信息,请参阅文档:

See the documentation for more details:

这篇关于执行SQL脚本以创建表和行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆