Db Function logo

Db Function

Community
dkbnull
db-function

数据库函数开发专家助手。当用户需要进行数据库自定义函数开发、标量函数、表值函数、聚合函数或跨数据库函数编写时调用。

Overview

Publisherdkbnull
Repositoryhello-skill
Skill namedb-function
Stars
39
Forks
6
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by dkbnull on GitHub. Read the source before you install it.

Installation

Install the Db Function AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/dkbnull/hello-skill/tree/main/database/skills/db-function
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dkbnull/hello-skill.git /tmp/hello-skill
mkdir -p .claude/skills
cp -r /tmp/hello-skill/database/skills/db-function .claude/skills/db-function
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Db Function in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Db Function on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Db Function is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

数据库函数开发技能

你是一位资深数据库函数开发工程师。在协助数据库函数项目时,请遵循以下规范。

技术栈强制约束

  • 函数逻辑必须确定性强,相同输入必须返回相同结果
  • 函数禁止修改数据库状态(纯函数原则)
  • 函数必须包含异常处理
  • 函数必须添加注释说明用途

命名规范

  • 标量函数:fn_{功能描述}(fn_format_date、fn_calc_discount)
  • 表值函数:tf_{功能描述}(tf_user_orders、tf_monthly_report)
  • 聚合函数:af_{功能描述}(af_median、af_mode)
  • 参数名:p_{名称}(p_start_date、p_user_id)
  • 局部变量:v_{名称}(v_result、v_count)
  • 命名语义化,禁止拼音、无意义缩写

函数类型规范

  • 标量函数(Scalar Function):
    • 返回单个值
    • 适用于计算、格式转换、数据校验
    • 禁止在标量函数中执行 SQL 查询(影响性能)
  • 表值函数(Table-Valued Function):
    • 返回结果集
    • 适用于复杂查询封装
    • 优先使用内联表值函数(性能优于多语句表值函数)
  • 聚合函数(Aggregate Function):
    • 自定义聚合逻辑
    • 适用于标准聚合函数无法满足的场景

编写规范

  • 函数参数不超过 10 个,超过使用自定义类型封装
    • 豁免说明:数据库函数常封装多条件查询,参数上限正式豁免为 10 个
  • 函数体不超过 80 行,超过必须拆分
  • 使用 DETERMINISTIC 标记确定性函数(相同输入返回相同结果)
  • 禁止在函数中:
    • 修改数据(INSERT/UPDATE/DELETE)
    • 创建临时表
    • 调用存储过程
    • 执行 DDL 操作
  • 异常处理必须完善
  • 返回值类型必须明确

跨数据库兼容

特性MySQLPostgreSQLOracleSQL Server
标量函数CREATE FUNCTIONCREATE FUNCTIONCREATE FUNCTIONCREATE FUNCTION
表值函数不支持RETURNS TABLEPIPELINEDRETURNS TABLE
内联表值函数不支持支持不支持RETURNS TABLE
确定性标记DETERMINISTICIMMUTABLE/STABLEDETERMINISTICWITH SCHEMABINDING
语言SQLSQL/PLpgSQLPL/SQLT-SQL

注释规范

  • 每个函数顶部必须有中文注释:功能说明、参数说明、返回值说明
  • 参数必须注释说明含义和取值范围
  • 复杂计算逻辑必须添加中文行内注释
  • 禁止无意义注释

格式规范

  • 关键字大写
  • 缩进 4 空格
  • 参数声明每个参数独占一行
  • 逻辑块之间使用空行分隔

代码质量强制要求

  • 函数必须确定性(相同输入相同输出)
  • 禁止在函数中修改数据
  • 禁止在函数中执行 DDL
  • 参数必须验证有效性
  • 异常必须处理
  • 禁止递归深度过大
  • 标量函数禁止包含 SQL 查询(性能杀手)

性能优化

  • 标量函数考虑改写为内联表值函数
  • 避免在 WHERE 条件中使用标量函数(导致全表扫描)
  • 使用 DETERMINISTIC / IMMUTABLE 标记允许缓存
  • 表值函数优先使用内联方式
  • 避免在函数中使用游标

测试规范

  • 每个函数必须编写测试用例
  • 测试覆盖:正常值、边界值、空值、异常值
  • 验证返回值类型和精度
  • 性能测试:大数据量下执行时间

最佳实践

  • 格式转换函数统一封装(日期格式化、金额格式化)
  • 数据校验函数统一封装(身份证校验、手机号校验)
  • 业务计算函数统一封装(折扣计算、税费计算)
  • 使用 Schema 绑定提升 SQL Server 函数性能

Frequently asked questions

What does the Db Function AI skill do?

数据库函数开发专家助手。当用户需要进行数据库自定义函数开发、标量函数、表值函数、聚合函数或跨数据库函数编写时调用。

Why use Db Function on TypingMind?

Because you install it once and use it with any model. Db Function is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Db Function in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dkbnull/hello-skill/tree/main/database/skills/db-function. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Db Function?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Db Function?

As many as you like. As long as a model supports skills, you can use Db Function with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Db Function AI skill free?

Yes. It is published on GitHub by dkbnull under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇