Opening database file from within SQLite command-line shell

后端 未结 8 869
时光说笑
时光说笑 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条回答
  • 2021-01-29 22:10

    You can attach one and even more databases and work with it in the same way like using sqlite dbname.db

    sqlite3
    :
    sqlite> attach "mydb.sqlite" as db1;
    

    and u can see all attached databases with .databases

    where in normal way the main is used for the command-line db

    .databases
    seq  name             file                                                      
    ---  ---------------  ----------------------------------------------------------
    0    main                                                                       
    1    temp                                                                       
    2    ttt              c:\home\user\gg.ite                                   
    
    0 讨论(0)
  • 2021-01-29 22:13

    The command within the Sqlite shell to open a database is .open

    The syntax is,

    sqlite> .open dbasename.db
    

    If it is a new database that you would like to create and open, it is

    sqlite> .open --new dbasename.db
    

    If the database is existing in a different folder, the path has to be mentioned like this:

    sqlite> .open D:/MainFolder/SubFolder/...database.db
    

    In Windows Command shell, you should use '\' to represent a directory, but in SQLite directories are represented by '/'. If you still prefer to use the Windows notation, you should use an escape sequence for every '\'

    0 讨论(0)
提交回复
热议问题