Create SQL examples for OceanBase documentation with proper formatting, meaningful names, and separated results. Use when writing or reviewing example sections in OceanBase documentation.
This skill provides guidelines for creating SQL examples in OceanBase documentation.
Always prefix with prompt:
obclient> for default promptobclient [SCHEMA]> when schema context is relevantInclude semicolons in executable statements.
Example:
obclient [KILL_USER]> SHOW PROCESSLIST;
Separate from SQL statements:
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
Avoid simple names:
t1, t2, tg1, db1test_table, temp_dbUse business-meaningful names:
order_tg, product_tg, inventory_tgorder_table, user_info, product_catalogsales_db, customer_db, warehouse_dbWhy:
E-commerce:
orders, order_items, customers, productsorder_tg, product_tgecommerce_dbFinancial:
transactions, accounts, balancestransaction_tg, account_tgbanking_dbInventory:
warehouses, inventory_items, stock_movementswarehouse_tg, inventory_tglogistics_dbException: Only include these if they provide meaningful information for understanding the example.
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;
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)
);
Show the SQL statement:
obclient [SALES_DB]> SELECT * FROM order_table WHERE order_date >= '2024-01-01';
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
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
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
obclient> prefix