之前在【程式交易】自建資料庫的三個優點 這篇文章中提到自建資料庫的優點,優點包含輕易地進行雲端化、SQL指令的完美搭配與真正保有資料自主權,而缺點呢?──────就是要在學一個東西啦!現在會寫幾篇文章來讓大家學會如何架設並使用輕量級的SQLite資料庫。
安裝DB Browser for SQLite
軟體名稱:DB Browser for SQLite 官方網站:https://sqlitebrowser.org/ 下載頁面:https://sqlitebrowser.org/dl/ 適用平台:Windows、MacOS、Linux
首先進入SQLite Browser的網頁中,點選符合自己系統的連結進行下載。

安裝成功並執行,跳出以下視窗代表安裝成功。

建立第一個SQLite專案
點擊左上角的「新建資料庫」,並選擇想要建立資料庫的位置

新增資料表(Create Table)
點選Database Struture區域的Create Table

我們先來建立一個簡單的範例資料表,裡面包含使用者名稱、性別與年齡

新增資料表完成後,就可以在主視窗中看到剛剛建立完成的資料表內容

建立資料
手動按鈕新增
在Browse Data中,除了可以觀看資料內容外,也可以手動新增資料,點擊「新建記錄」,並可執行更改資料內容

SQL指令
另外可以選擇Execute SQL頁面中執行SQL指令,例如以下方式

抓取資料
手動查找
一樣打開Browse Data的區塊,可以選擇資料表,並執行篩選過濾

SQL指令
在Execute SQL的區塊也一樣可進行SQL指令的查找
