SQLite資料庫下載、安裝和學習

來源:互聯網
上載者:User

標籤:

SQLite 是一個開源的嵌入式關聯式資料庫,實現自包容、零配置、支援事務的SQL資料庫引擎。 其特點是高度便攜、使用方便、結構緊湊、高效、可靠。與其他資料庫管理系統不同,SQLite 的安裝和運行非常簡單,在大多數情況下 - 只要確保SQLite的二進位檔案存在即可開始建立、串連和使用資料庫。如果您正在尋找一個嵌入式資料庫專案或解決方案,SQLite是絕對值得考慮。

http://database.51cto.com/art/201205/335411.htm

SQLite on Windows

1)進入 SQL 下載頁面:http://www.sqlite.org/download.html

2)下載 Windows 下的先行編譯二進位檔案包:

 

sqlite-shell-win32-x86-<build#>.zip
sqlite-dll-win32-x86-<build#>.zip

 

注意: <build#> 是 sqlite 的編譯版本號碼

將 zip 檔案解壓到你的磁碟,並將解壓後的目錄添加到系統的 PATH 變數中,以方便在命令列中執行 sqlite 命令。

 可選: 如果你計劃發布基於 sqlite 資料庫的應用程式,你還需要下載源碼以便編譯和利用其 API

sqlite-amalgamation-<build#>.zip

3. 建立首個 SQLite 資料庫

現在你已經安裝了 SQLite 資料庫,接下來我們建立首個資料庫。在命令列視窗中輸入如下命令來建立一個名為 test.db 的資料庫。

  sqlite3 test.db 

建立表:

  sqlite> create table mytable(id integer primary key, value text);  

  2 columns were created.  

該表包含一個名為 id 的主鍵欄位和一個名為 value 的文字欄位

注意: 最少必須為建立的資料庫建立一個表或者視圖,這麼才能將資料庫儲存到磁碟中,否則資料庫不會被建立。

這時候test.db建立好了預設在C:\Users\Administrator\目錄下

接下來往表裡中寫入一些資料:

     sqlite> insert into mytable(id, value) values(1, ‘Micheal‘);  

     sqlite> insert into mytable(id, value) values(2, ‘Jenny‘);  

     sqlite> insert into mytable(value) values(‘Francis‘);

     sqlite> insert into mytable(value) values(‘Kerk‘);

查詢資料:

     sqlite> select * from mytable;  

     1|Micheal  

     2|Jenny  

     3|Francis  

     4|Kerk 

 

SQLite資料庫下載、安裝和學習

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.