如何针对SQLite 3数据库文件执行sql脚本文件?

时间:2022-11-22 01:15:35

What is an SQLite 3 (3.7.11) analogue of MySQL's

什么是MySQL的SQLite 3(3.7.11)模拟

mysql -p -u username database_name < file.sql

to execute all the queries in a given SQL script file against a specified database?

执行给定SQL脚本文件中针对指定数据库的所有查询?

2 个解决方案

#1


59  

This should work:

这应该工作:

[someone@somewhere ~]$ echo "select * from sometable;" > file.sql
[someone@somewhere ~]$ sqlite3 file.db < file.sql 
10/02/2012
11/01/2012
09/03/2012

#2


5  

The following should work as well:

以下应该也可以:

 echo "SELECT id, username, email FROM fos_user_user;" | sqlite3 app/data.db3

#1


59  

This should work:

这应该工作:

[someone@somewhere ~]$ echo "select * from sometable;" > file.sql
[someone@somewhere ~]$ sqlite3 file.db < file.sql 
10/02/2012
11/01/2012
09/03/2012

#2


5  

The following should work as well:

以下应该也可以:

 echo "SELECT id, username, email FROM fos_user_user;" | sqlite3 app/data.db3