sqlite能用命令执行语句吗?
发布网友
发布时间:2022-04-08 17:47
我来回答
共1个回答
热心网友
时间:2022-04-08 19:17
可以:
tim@crunchbang:~/workspace$ cat init.sql
create table test (
name varchar(32),
mail varchar(64),
mobi varchar(11)
);
insert into test values ('Tim Wang', 'tim@126.com','');
insert into test values ('Bruce Wang', 'bruce@126.com', '');
insert into test values ('Hans Wang', 'hans@126.com', '');
tim@crunchbang:~/workspace$ cat list.sql
select * from test;
tim@crunchbang:~/workspace$ sqlite3 test.db < init.sql
tim@crunchbang:~/workspace$ sqlite3 test.db < list.sql
Tim Wang|tim@126.com|
Bruce Wang|bruce@126.com|
Hans Wang|hans@126.com|
tim@crunchbang:~/workspace$追问后面能直接加语句,而不是加文件的吗?
追答tim@crunchbang:~$ echo "select datetime('now');"|sqlite3
2013-06-17 01:12:23
tim@crunchbang:~$