-- SQLite 數據庫初始化腳本 -- 創建 orders 表 CREATE TABLE IF NOT EXISTS orders ( id INTEGER PRIMARY KEY AUTOINCREMENT, customer_name TEXT NOT NULL, product_name TEXT NOT NULL, quantity INTEGER NOT NULL, price REAL NOT NULL, status TEXT DEFAULT 'pending', created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); -- 插入示例數據 INSERT INTO orders (customer_name, product_name, quantity, price, status) VALUES ('張三', 'iPhone 15', 1, 999.99, 'completed'), ('李四', 'MacBook Pro', 1, 1999.99, 'pending'), ('王五', 'iPad Air', 2, 599.99, 'shipped'), ('趙六', 'Apple Watch', 1, 399.99, 'delivered'), ('錢七', 'AirPods Pro', 1, 249.99, 'processing'); -- 創建索引以提高查詢性能 CREATE INDEX IF NOT EXISTS idx_customer_name ON orders(customer_name); CREATE INDEX IF NOT EXISTS idx_product_name ON orders(product_name); CREATE INDEX IF NOT EXISTS idx_status ON orders(status); CREATE INDEX IF NOT EXISTS idx_created_at ON orders(created_at);