Opening database file from within SQLite command-line shell

后端 未结 8 878
时光说笑
时光说笑 2021-01-29 21:07

I\'m using the SQLite Command Line Shell. As documented, I can open a database by supplying it as an argument to the executable:

sqlite3 data.db

8条回答
  •  闹比i
    闹比i (楼主)
    2021-01-29 21:55

    create different db files using
          >sqlite3 test1.db
    sqlite> create table test1 (name text);
    sqlite> insert into test1 values('sourav');
    sqlite>.exit
          >sqlite3 test2.db
    sqlite> create table test2 (eid integer);
    sqlite> insert into test2 values (6);
    sqlite>.exit
          >sqlite
    SQLite version 3.8.5 2014-06-04 14:06:34
    Enter ".help" for usage hints.
    Connected to a transient in-memory database.
    Use ".open FILENAME" to reopen on a persistent database.
    sqlite> .open test1.db
    sqlite> select * from test1;
    sourav
    sqlite> .open test2.db
    sqlite> select * from test1;
    Error: no such table: test1
    sqlite> select * from test2;
    6
    sqlite> .exit
          >
    
    Thank YOU.
    

提交回复
热议问题