如何将 .sql 文件导入 SQLite 3? [英] How do I import .sql files into SQLite 3?
本文介绍了如何将 .sql 文件导入 SQLite 3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有包含以下内容的 .sql 文件:
I have .sql files which have the following content:
#cat db.sql
create table server(name varchar(50),ipaddress varchar(15),id init)
create table client(name varchar(50),ipaddress varchar(15),id init)
如何将此文件导入 SQLite 以便自动创建这些文件?
How do I import this file into SQLite so that these are created automatically?
推荐答案
来自 sqlite 提示:
From a sqlite prompt:
sqlite> .read db.sql
或者:
cat db.sql | sqlite3 database.db
此外,您的 SQL 无效 - 您需要在语句末尾使用 ;
:
Also, your SQL is invalid - you need ;
on the end of your statements:
create table server(name varchar(50),ipaddress varchar(15),id init);
create table client(name varchar(50),ipaddress varchar(15),id init);
这篇关于如何将 .sql 文件导入 SQLite 3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文