資料庫
在 Fricle 中連線至資料庫、執行查詢,並編輯資料或資料表結構。Database 支援 SQLite、PostgreSQL、MySQL、DynamoDB、MongoDB 和 Redis。可用的命令和編輯選項取決於資料庫提供者及您的權限。
範例 · 在 PostgreSQL 中檢視上個月的訂單
在 Database 中選取 Add connection,然後選擇 PostgreSQL。輸入團隊的伺服器資訊和認證資料,再選取 Test connection 和 Save。之後若要編輯已儲存的連線,請開啟 Connection settings。
開啟 New query,輸入下方查詢,然後選取 Execute current statement。在結果格線中查看各狀態的訂單筆數和總額。
sql SELECT status, COUNT(*) AS orders, SUM(total) AS total_sales FROM public.orders WHERE ordered_at >= date_trunc('month', CURRENT_DATE) - INTERVAL '1 month' AND ordered_at < date_trunc('month', CURRENT_DATE) GROUP BY status ORDER BY status;若要更正單筆訂單,請在資料庫側邊欄開啟 public → Tables → orders。在資料表格線中編輯狀態,然後選取 Apply changes。上方的彙總結果為唯讀。
若要新增欄,請開啟資料表功能表,然後選擇 Alter table…。新增欄後,選取 Apply changes。在 Apply SQL script to database 中檢查產生的陳述式,再選取其中的 Apply changes 執行。
若要重複執行某個查詢,請使用 Save editor text as a snippet (selection, or all),之後可在 Snippets 中找到。
範例 · 開啟本機 SQLite 檔案
從 Documents 開啟 sales.sqlite,選取 sales,並確認收據 R-103 的總額為 $48。
