Files
Letters/xinhan/schema.md
T
biss 924e4656aa
Vercel Deploy / deploy (push) Successful in 1m1s
信函更新
2026-06-17 20:17:03 +08:00

56 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Xinhan 数据表结构说明
本文档提供针对 xinhan 表的 SQL 创建语句与示例查询。注意:以下 SQL 仅用于创建结构;本任务仅生成 MD 文档,不执行 SQL。
## 数据字段与含义
- self_number: 自编号,文本类型,用于内部检索
- tracking_number: 快递号,文本类型,用于记录物流单号
- recipient: 收件人,为文本类型,必填
- content: 内容物,文本型,可包含多行描述
- sent_date: 寄出日期,时间戳(timestamptz/ TIMESTAMP),必填
- destination: 寄达地,文本
- arrival_date: 寄达日期,时间戳
## 建表 SQLPostgreSQLSupabase/ Postgres 兼容)
```sql
CREATE TABLE xinhan (
id SERIAL PRIMARY KEY,
self_number TEXT,
tracking_number TEXT,
recipient TEXT NOT NULL,
content TEXT,
sent_date TIMESTAMP WITHOUT TIME ZONE NOT NULL,
destination TEXT,
arrival_date TIMESTAMP WITHOUT TIME ZONE
);
-- 索引,提升按自编号、快递号、收件人、寄出日期/寄达日期的查询性能
CREATE INDEX IF NOT EXISTS idx_xinhan_self_number ON xinhan (self_number);
CREATE INDEX IF NOT EXISTS idx_xinhan_tracking_number ON xinhan (tracking_number);
CREATE INDEX IF NOT EXISTS idx_xinhan_recipient ON xinhan (recipient);
CREATE INDEX IF NOT EXISTS idx_xinhan_sent_date ON xinhan (sent_date);
CREATE INDEX IF NOT EXISTS idx_xinhan_arrival_date ON xinhan (arrival_date);
```
## 示例查询
```sql
-- 查询某个收件人相关信函的简单示例
SELECT * FROM xinhan
WHERE recipient ILIKE '%张三%'
ORDER BY sent_date DESC
LIMIT 100;
-- 根据自编号查询示例
SELECT * FROM xinhan
WHERE self_number ILIKE '%XH-2026-001%'
ORDER BY sent_date DESC
LIMIT 100;
-- 根据日期范围查询示例
SELECT * FROM xinhan
WHERE sent_date BETWEEN '2024-01-01' AND '2026-12-31'
ORDER BY sent_date DESC;
```
> 说明:此文件仅用于记录数据库结构与查询示例,实际部署请在你的数据库实例中执行上述 SQL。