oceanbase-examples
10
总安装量
5
周安装量
#30164
全站排名
安装命令
npx skills add https://github.com/amber-moe/oceanbase-doc-skills --skill oceanbase-examples
Agent 安装分布
cursor
3
claude-code
3
trae
2
kilo
1
windsurf
1
Skill 文档
OceanBase Documentation Examples
This skill provides guidelines for creating SQL examples in OceanBase documentation.
Example structure
SQL statements
Always prefix with prompt:
obclient>for default promptobclient [SCHEMA]>when schema context is relevant
Include semicolons in executable statements.
Example:
obclient [KILL_USER]> SHOW PROCESSLIST;
Query results
Separate from SQL statements:
- Place SQL in one code block
- Place results in another code block
- Connect with descriptive text like “æ¥è¯¢ç»æå¦ä¸ï¼” or “Query results:”
Example:
obclient [KILL_USER]> SHOW PROCESSLIST;
æ¥è¯¢ç»æå¦ä¸ï¼
+------------+-----------+----------------------+-----------+---------+------+--------+------------------+
| ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO |
+------------+-----------+----------------------+-----------+---------+------+--------+------------------+
| 3221487726 | KILL_USER | 100.xx.xxx.xxx:34803 | KILL_USER | Query | 0 | ACTIVE | SHOW PROCESSLIST |
+------------+-----------+----------------------+-----------+---------+------+--------+------------------+
1 row in set
Naming conventions
Use meaningful names
Avoid simple names:
- â
t1,t2,tg1,db1 - â
test_table,temp_db
Use business-meaningful names:
- â
Table groups:
order_tg,product_tg,inventory_tg - â
Tables:
order_table,user_info,product_catalog - â
Databases:
sales_db,customer_db,warehouse_db
Why:
- Helps users understand real-world scenarios
- Makes examples more relatable
- Demonstrates practical applications
Example scenarios
E-commerce:
- Tables:
orders,order_items,customers,products - Table groups:
order_tg,product_tg - Databases:
ecommerce_db
Financial:
- Tables:
transactions,accounts,balances - Table groups:
transaction_tg,account_tg - Databases:
banking_db
Inventory:
- Tables:
warehouses,inventory_items,stock_movements - Table groups:
warehouse_tg,inventory_tg - Databases:
logistics_db
What to include
Include:
- â Query result tables (when helpful)
- â Error messages (when demonstrating error handling)
- â Descriptive output (when it adds value)
Exclude:
- â “Query OK” messages
- â “Query OK, 0 rows affected”
- â “Query OK, 1 row affected”
- â Generic success messages
Exception: Only include these if they provide meaningful information for understanding the example.
Example workflow
Step 1: Create context
Set up meaningful scenario:
obclient [SYS]> CREATE USER sales_user IDENTIFIED BY 'password123';
obclient [SYS]> GRANT CREATE SESSION TO sales_user;
obclient [SYS]> CREATE DATABASE sales_db;
obclient [SYS]> USE sales_db;
Step 2: Create objects
Use meaningful names:
obclient [SALES_DB]> CREATE TABLE order_table (
order_id BIGINT PRIMARY KEY,
customer_id BIGINT,
order_date DATE,
total_amount DECIMAL(10,2)
);
Step 3: Demonstrate feature
Show the SQL statement:
obclient [SALES_DB]> SELECT * FROM order_table WHERE order_date >= '2024-01-01';
Step 4: Show results
Separate code block with descriptive text:
æ¥è¯¢ç»æå¦ä¸ï¼
+----------+-------------+------------+--------------+
| order_id | customer_id | order_date | total_amount |
+----------+-------------+------------+--------------+
| 101 | 1001 | 2024-01-15 | 1250.00 |
| 102 | 1002 | 2024-01-20 | 850.50 |
+----------+-------------+------------+--------------+
2 rows in set
Complex examples
Multi-step examples
For complex workflows, break into logical steps:
Step 1: Setup
obclient [SYS]> CREATE USER admin_user IDENTIFIED BY 'admin123';
obclient [SYS]> GRANT ALTER SYSTEM TO admin_user;
Step 2: Create table group
obclient [ADMIN_USER]> CREATE TABLEGROUP order_tg;
Step 3: Create table
obclient [ADMIN_USER]> CREATE TABLE order_table (
order_id BIGINT PRIMARY KEY,
customer_id BIGINT
) TABLEGROUP = order_tg;
Step 4: Verify
obclient [ADMIN_USER]> SHOW TABLEGROUPS;
æ¥è¯¢ç»æå¦ä¸ï¼
+-----------+------------+
| TableName | TableGroup |
+-----------+------------+
| order_table | order_tg |
+-----------+------------+
1 row in set
Error examples
When demonstrating error handling:
obclient [USER]> CREATE TABLE invalid_table (
id INT PRIMARY KEY,
name VARCHAR(10)
) PARTITION BY HASH(id) PARTITIONS 0;
é误信æ¯å¦ä¸ï¼
ERROR 1235 (42000): Invalid partition count
Best practices
- Start simple, add complexity gradually
- Use consistent naming throughout example
- Show realistic data in results
- Include comments when helpful (but keep them concise)
- Test examples to ensure they work
- Follow test cases when they differ from parser definitions
Quality checklist
- SQL statements have
obclient>prefix - SQL and results in separate code blocks
- Meaningful, business-oriented names used
- No unnecessary “Query OK” messages
- Results formatted clearly
- Example demonstrates real-world usage
- All statements are executable and tested