SQLite数据库安装与使用

 

Here’s the table of contents:

  1. 下载
  2. 新建db
  3. 创建表
  4. 写入数据
  5. 查询数据

下载

sqlite-tools-win-x64-3470100.zip

  • 解压后将目录配置到用户环境变量中,在Path中新增目录即可(例如解压后文件夹名称为C:/mm/sql,将该文件夹配置到Path中即可)

新建db

sqlite3 mydatabase.db

创建表

CREATE TABLE products (
  id INTEGER PRIMARY KEY,
  name TEXT,
  price REAL
);

写入数据

INSERT INTO products (name, price) VALUES
  ('Widget', 19.99),
  ('Gadget', 29.99),
  ('Gizmo', 39.99),
  ('Smart Watch', 199.99),
  ('Wireless Earbuds', 89.99),
  ('Portable Charger', 24.99),
  ('Bluetooth Speaker', 79.99),
  ('Phone Stand', 15.99),
  ('Laptop Sleeve', 34.99),
  ('Mini Drone', 299.99),
  ('LED Desk Lamp', 45.99),
  ('Keyboard', 129.99),
  ('Mouse Pad', 12.99),
  ('USB Hub', 49.99),
  ('Webcam', 69.99),
  ('Screen Protector', 9.99),
  ('Travel Adapter', 27.99),
  ('Gaming Headset', 159.99),
  ('Fitness Tracker', 119.99),
  ('Portable SSD', 179.99);

查询数据

SELECT * FROM products;