### Example: Install OceanBase RPM Package Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/400.deploy/300.deploy-oceanbase-enterprise-edition/400.deploy-through-the-command-line/200.deploy-the-oceanbase-cluster-command-line/200.deploy-the-quorum-high-availability-service.md An example of installing a specific OceanBase RPM package. This command installs the package and shows the progress. ```shell [root@xxx /home/admin/rpm]# rpm -ivh oceanbase-4.2.0.0-100000052023073123.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:oceanbase-4.2.0.0-100000052023073################################# [100%] ``` -------------------------------- ### Example OBProxy RPM Installation Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/400.deploy/300.deploy-oceanbase-enterprise-edition/400.deploy-through-the-command-line/300.deploy-obproxy-command-line.md Demonstrates the output of installing an OBProxy RPM package. This shows the package preparation and installation progress. ```bash [root@xxx admin]# rpm -ivh obproxy-4.0.0-20230109154442.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:obproxy-4.0.0-20230109154442.el7 ################################# [100%] ``` -------------------------------- ### Start Transaction Example Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/500.sql-reference/100.sql-syntax/200.common-tenant-of-mysql-mode/400.functions-of-mysql-mode/600.information-functions-of-mysql-mode/1050.ob_transaction_id-of-mysql-mode.md Demonstrates how to start a transaction using the BEGIN statement before querying the transaction ID. ```shell obclient [test]> BEGIN; ``` -------------------------------- ### Create a Keystore Example Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/500.sql-reference/100.sql-syntax/300.common-tenant-of-oracle-mode/900.sql-statement-of-oracle-mode/100.ddl-of-oracle-mode/1700.create-keystore-of-oracle-mode.md Example of creating a Keystore named `keystore1` with a password. Ensure the password meets the length and starting character requirements. ```sql obclient> ADMINISTER KEY MANAGEMENT CREATE KEYSTORE keystore1 IDENTIFIED BY **1***; ``` -------------------------------- ### Clone and Install MySQL Driver (Alternative) Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/300.develop/100.application-development-of-mysql-mode/200.sample-program-of-mysql-mode/400.go-of-mysql-mode/1.go-sql-driver-mysql-connection-oceanbase-sample-program.md If `go get` fails, clone the repository and use `go install`. Replace `/usr/local/go/src` with your actual Go installation path. ```bash cd /usr/local/go/src git clone https://github.com/go-sql-driver/mysql.git go install mysql ``` -------------------------------- ### Install obshell-sdk-go Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/1500.Components-and-Tools/100.manage/100.obshell/500.obshell-sdk-reference/200.go/100.quickstart-of-go.md Use 'go get' to install the obshell-sdk-go package. ```shell go get github.com/oceanbase/obshell-sdk-go ``` -------------------------------- ### Example WSL Version Output Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/400.deploy/500.deploy-oceanbase-database-community-edition/800.deploy-oceanbase-desktop.md This is an example of the expected output when verifying the WSL installation, indicating a successful setup of WSL 2. ```shell WSL version: 2.5.7.0 Kernel version: 6.6.87.1-1 WSLg version: 1.0.66 MSRDC version: 1.2.6074 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.26100.1-240331-1435.ge-release Windows: 10.0.19045.5854 ``` -------------------------------- ### Example: Start Zone 'zone4' Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/600.manage/100.cluster-management/300.common-cluster-operations/800.1.start-a-zone.md This example demonstrates starting a zone named 'zone4' using the ALTER SYSTEM START ZONE command. It shows the expected output upon successful execution. ```sql obclient [(none)]> ALTER SYSTEM START ZONE zone4; Query OK, 0 rows affected ``` -------------------------------- ### Example: Full Directory and Link Setup Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/400.deploy/300.deploy-oceanbase-enterprise-edition/400.deploy-through-the-command-line/200.deploy-the-oceanbase-cluster-command-line/200.deploy-the-quorum-high-availability-service.md A comprehensive example demonstrating the creation of data directories and soft links for a cluster named 'obdemo'. This illustrates the practical application of the preceding commands. ```shell su - admin mkdir -p /data/1/obdemo/{etc3,sstable,slog} mkdir -p /data/log1/obdemo/{clog,etc2} mkdir -p /home/admin/oceanbase/store/obdemo for t in {etc3,sstable,slog};do ln -s /data/1/obdemo/$t /home/admin/oceanbase/store/obdemo/$t; done for t in {clog,etc2};do ln -s /data/log1/obdemo/$t /home/admin/oceanbase/store/obdemo/$t; done ``` -------------------------------- ### Create WebLogic Domain and Start Server Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/680.ecological-integration/500.sql-development/100.weblogic.md After installation, this command sequence sets up the WebLogic environment, creates a new domain, and starts the WebLogic server instance. Ensure the JAVA_HOME environment variable is set correctly. ```bash source /opt/weblogic/Oracle/Middleware/wlserver/server/bin/setWLSEnv.sh mkdir -p /opt/weblogic/Oracle/Middleware/user_projects/domains/hnDoMain cd /opt/weblogic/Oracle/Middleware/user_projects/domains/hnDoMain $JAVA_HOME/bin/java $JAVA_OPTIONS -Xmx1024m -XX:MaxPermSize=2048m weblogic.Server ``` -------------------------------- ### Install Go MySQL Driver using go install Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/200.quickstart/300.create-sample-application-of-mysql-mode/400.golang-application-of-mysql-model.md Install the Go MySQL Driver by cloning the repository and using the `go install` command. This is an alternative if `go get` encounters issues. ```bash cd /usr/local/go/src git clone https://github.com/go-sql-driver/mysql.git ``` ```bash go install mysql ``` -------------------------------- ### Install OBProxy with Custom Prefix Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/400.deploy/300.deploy-oceanbase-enterprise-edition/400.deploy-through-the-command-line/300.deploy-obproxy-command-line.md Installs the OBProxy RPM package to a specified directory using the `--prefix` option. This example installs OBProxy into the `/home/admin` directory. ```bash rpm -ivh --prefix=/home/admin $rpm_name ``` -------------------------------- ### Example Observer Process Information Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/600.manage/100.cluster-management/300.common-cluster-operations/1500.oceanbase-version-upgrade/200.upgrade-oceanbase-enterprise-edition/200.arbitration-services-version-upgrade.md An example output from the 'ps -ef | grep observer' command, showing the user, PID, and the command used to start the observer process. ```shell admin 103364 1 99 2022 ? 51-17:24:41 /home/admin/oceanbase/bin/observer ``` -------------------------------- ### Create Procedure and Get DDL Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/700.reference/600.pl-reference/300.pl-oracle/1400.pl-system-package-oracle/9900.dbms-metadata-oracle/200.get-ddl-oracle.md This example shows how to create a procedure and then fetch its DDL using `GET_DDL`. Server output must be enabled to display the result. ```sql create procedure tEst1(tEst1 int, "nAMe" varchar2, age float) as begin null; end; / -- 设置服务器输出,允许在 SQL 命令行界面打印消息。 set serveroutput on; -- 调用 DBMS_METADATA.GET_DDL 函数获取名为 'TEST1' 的存储过程的 DDL 语句。 call dbms_output.put_line(dbms_metadata.get_ddl('PROCEDURE','TEST1')); ``` -------------------------------- ### Example Disk Information Output Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/400.deploy/500.deploy-oceanbase-database-community-edition/200.local-deployment/200.environment-and-configuration-checks/400.plan-disks-optional.md This example output from `df -h` illustrates how data, clog (redo), and installation disks are typically represented. It shows the filesystem, size, used space, available space, and mount point for each disk. ```bash Filesystem Size Used Avail Use% Mounted on devtmpfs 31G 0 31G 0% /dev tmpfs 31G 0 31G 0% /dev/shm tmpfs 31G 516K 31G 1% /run tmpfs 31G 0 31G 0% /sys/fs/cgroup /dev/vda1 493G 171G 302G 37% / tmpfs 6.2G 0 6.2G 0% /run/user/0 /dev/vdd1 984G 77M 934G 1% /data /dev/vdc1 196G 61M 186G 1% /redo /dev/vdb1 492G 73M 467G 1% /home/admin/oceanbase ``` -------------------------------- ### Query Plan Example (Before Full Estimation) Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/800.configuration-items-and-system-variables/200.system-variable/300.global-system-variable/850.cardinality_estimation_model-global.md This is an example of a query plan output before setting the `cardinality_estimation_model` to 'full'. Note the estimated rows. ```shell +------------------------------------------------------------------------------------------+ | Query Plan | +------------------------------------------------------------------------------------------+ | =============================================== | | |ID|OPERATOR |NAME|EST.ROWS|EST.TIME(us)| | | ----------------------------------------------- | | |0 |TABLE FULL SCAN|t1 |31 |735 | | | =============================================== | | Outputs & filters: | | ------------------------------------- | | 0 - output([t1.c1], [t1.c2]), filter([t1.c2 = 1], [t1.c1 = 1]), rowset=256 | | access([t1.c1], [t1.c2]), partitions(p0) | | is_index_back=false, is_global_index=false, filter_before_indexback[false,false], | | range_key([t1.__pk_increment]), range(MIN ; MAX)always true | +------------------------------------------------------------------------------------------+ 11 rows in set (0.004 sec) ``` -------------------------------- ### Query Plan Example (After Full Estimation) Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/800.configuration-items-and-system-variables/200.system-variable/300.global-system-variable/850.cardinality_estimation_model-global.md This is an example of a query plan output after setting the `cardinality_estimation_model` to 'full'. Compare the 'EST.ROWS' with the previous example. ```shell +------------------------------------------------------------------------------------------+ | Query Plan | +------------------------------------------------------------------------------------------+ | =============================================== | | |ID|OPERATOR |NAME|EST.ROWS|EST.TIME(us)| | | ----------------------------------------------- | | |0 |TABLE FULL SCAN|t1 |98 |738 | | | =============================================== | | Outputs & filters: | | ------------------------------------- | | 0 - output([t1.c1], [t1.c2]), filter([t1.c2 = 1], [t1.c1 = 1]), rowset=256 | | access([t1.c1], [t1.c2]), partitions(p0) | | is_index_back=false, is_global_index=false, filter_before_indexback[false,false], | | range_key([t1.__pk_increment]), range(MIN ; MAX)always true | +------------------------------------------------------------------------------------------+ 11 rows in set (0.003 sec) ``` -------------------------------- ### Get Week Number with Mode 0 Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/500.sql-reference/100.sql-syntax/200.common-tenant-of-mysql-mode/400.functions-of-mysql-mode/200.single-row-functions-of-mysql-mode/100.date-and-time-functions-of-mysql-mode/5500.week-of-mysql-mode.md This example demonstrates how to use the WEEK() function with mode 0, where Sunday is the first day of the week and the week numbering starts from 0. ```sql SELECT WEEK('2021-01-01',0); ``` -------------------------------- ### Setup for PURGE Examples Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/500.sql-reference/100.sql-syntax/300.common-tenant-of-oracle-mode/900.sql-statement-of-oracle-mode/200.dml-of-oracle-mode/400.purge-of-oracle-mode.md These SQL statements set up sample tables and indexes, then drop them to populate the recycle bin for subsequent PURGE operations. ```sql obclient> CREATE TABLE tbl1(col1 INT,col2 INT); Query OK, 0 rows affected obclient> CREATE TABLE tbl2(col1 INT,col2 INT); Query OK, 0 rows affected obclient> CREATE INDEX tbl1_idx1 ON tbl1(col1); Query OK, 0 rows affected obclient> CREATE INDEX tbl2_idx2 ON tbl2(col1); Query OK, 0 rows affected obclient> DROP TABLE tbl1; Query OK, 0 rows affected obclient> DROP TABLE tbl2; Query OK, 0 rows affected obclient> SHOW RECYCLEBIN; +-----------------------------------+----------------------------------+-------+------------------------------+ | OBJECT_NAME | ORIGINAL_NAME | TYPE | CREATETIME | +-----------------------------------+----------------------------------+-------+------------------------------+ | RECYCLE_$_100004_1634626847891416 | __idx_1101710651081601_TBL1_IDX1 | INDEX | 19-OCT-21 03.00.47.891270 PM | | RECYCLE_$_100004_1634626847895656 | TBL1 | TABLE | 19-OCT-21 03.00.47.895431 PM | | RECYCLE_$_100004_1634626853379432 | __idx_1101710651081602_TBL2_IDX2 | INDEX | 19-OCT-21 03.00.53.378871 PM | | RECYCLE_$_100004_1634626853383304 | TBL2 | TABLE | 19-OCT-21 03.00.53.383100 PM | +-----------------------------------+----------------------------------+-------+------------------------------+ 4 rows in set ``` -------------------------------- ### Example OceanBase RPM Installation Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/400.deploy/300.deploy-oceanbase-enterprise-edition/400.deploy-through-the-command-line/200.deploy-the-oceanbase-cluster-command-line/200.deploy-the-quorum-high-availability-service.md An example of installing the OceanBase Database RPM package, showing the package name and version. ```shell [root@xxx /home/admin/rpm]# rpm -ivh oceanbase-4.2.0.0-100000052023073123.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:oceanbase-4.2.0.0-100000052023073################################# [100%] ``` -------------------------------- ### HTTP GET Request Example Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/1500.Components-and-Tools/100.manage/100.obshell/400.obshell-api-reference/300.unit-management/200.get-all-resource-specifications.md An example of an HTTP GET request to the resource specifications endpoint, including the host and port. ```http GET 10.10.10.1:2886/api/v1/units/config ``` -------------------------------- ### Perform Switchover to Standby Tenant (Example) Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/600.manage/400.high-availability/300.physical-standby-database-disaster-recovery/600.role-switch/200.perform-switchover.md Example of switching a tenant named 'mysql2' to a standby role using the obclient. ```shell obclient> ALTER SYSTEM SWITCHOVER TO STANDBY TENANT = mysql2; ``` -------------------------------- ### GET Request Example for Unit Configuration Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/1500.Components-and-Tools/100.manage/100.obshell/400.obshell-api-reference/300.unit-management/300.query-the-specified-unit-information.md This example demonstrates how to make a GET request to retrieve the configuration details for a specific unit resource specification by its name. ```shell GET 10.10.10.1:2886/api/v1/unit/config/s1 ``` -------------------------------- ### Example: Create Table and Insert Data Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/500.sql-reference/100.sql-syntax/200.common-tenant-of-mysql-mode/600.sql-statement-of-mysql-mode/2400.create-restore-point-of-mysql-mode.md Demonstrates the creation of a sample table and insertion of initial data, which serves as a baseline before creating a restore point. ```sql obclient> CREATE TABLE test1 (c1 INT,c2 INT); ``` ```sql obclient> INSERT INTO test1(c1,c2) values (1,1); ``` -------------------------------- ### Perform Switchover to Primary Tenant (Example) Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/600.manage/400.high-availability/300.physical-standby-database-disaster-recovery/600.role-switch/200.perform-switchover.md Example of switching a standby tenant named 'standby2' to a primary role using the obclient. ```shell obclient> ALTER SYSTEM SWITCHOVER TO PRIMARY TENANT = standby2; ``` -------------------------------- ### Create WebLogic Installation Directories Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/680.ecological-integration/500.sql-development/100.weblogic.md Creates necessary directories for WebLogic installation and sets ownership and permissions for the weblogic user. ```bash mkdir -p /opt/weblogic/oraInventory mkdir -p /opt/weblogic/Oracle mkdir -p /opt/weblogic/Oracle/Middleware chmod 777 /opt/weblogic chown -R weblogic:weblogic /opt/weblogic ``` -------------------------------- ### Request example for getting all resource pools Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/1500.Components-and-Tools/100.manage/100.obshell/400.obshell-api-reference/400.resource-pool-management/100.get-all-resource-pool-specifications.md This is an example of an HTTP GET request to retrieve all resource pool specifications. Ensure the IP address and port are correct for your cluster. ```http GET 10.10.10.1:2886/api/v1/resource-pools ``` -------------------------------- ### Running the Golang Application Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/200.quickstart/300.create-sample-application-of-mysql-mode/400.golang-application-of-mysql-model.md Commands to set up the Go environment and execute a sample Golang application. This includes setting the PATH and running the Go program directly or building a binary first. ```bash // Configure temporary environment variables based on the installation path of the Go language. export PATH=$PATH:/usr/local/go/bin // Execute the sample script. go run test.go // Alternatively, generate a binary file and then run it. go build test.go ./test ``` -------------------------------- ### Install Dependencies with UV Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/680.ecological-integration/1100.AI/700.trae.md Create a virtual environment and install project dependencies using uv. Ensure you are in the mcp-oceanbase directory. ```shell uv venv source .venv/bin/activate uv pip install . ``` -------------------------------- ### Create and Populate Tables Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/200.quickstart/200.get-started-with-oceanbase-sql/200.basic-sql-operations-of-mysql-mode.md Demonstrates the creation of tables `t4` and `t5`, including a partitioned table, and populating them with initial data. This setup is used for subsequent update operations. ```sql obclient> CREATE TABLE t4(c1 INT PRIMARY KEY, c2 INT); Query OK, 0 rows affected obclient> INSERT t4 VALUES(10,10),(20,20),(30,30),(40,40); Query OK, 4 rows affected Records: 4 Duplicates: 0 Warnings: 0 obclient> SELECT * FROM t4; +----+------+ | c1 | c2 | +----+------+ | 10 | 10 | | 20 | 20 | | 30 | 30 | | 40 | 40 | +----+------+ 4 rows in set obclient> CREATE TABLE t5(c1 INT PRIMARY KEY, c2 INT) PARTITION BY KEY(c1) PARTITIONS 4; Query OK, 0 rows affected obclient> INSERT t5 VALUES(50,50),(10,10),(20,20),(30,30); Query OK, 4 rows affected Records: 4 Duplicates: 0 Warnings: 0 obclient> SELECT * FROM t5; +----+------+ | c1 | c2 | +----+------+ | 20 | 20 | | 10 | 10 | | 50 | 50 | | 30 | 30 | +----+------+ 4 rows in set ``` -------------------------------- ### Example: Marking Multiple Savepoints Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/300.develop/100.application-development-of-mysql-mode/600.transaction-in-develop-of-mysql-mode/300.transaction-savepoints-of-mysql-mode/100.mark-a-savepoint-of-mysql-mode.md This example demonstrates starting a transaction, performing inserts, and marking multiple savepoints at different stages. Ensure autocommit is disabled before starting the transaction. ```sql SET SESSION autocommit=0; ``` ```sql BEGIN; ``` ```sql INSERT INTO ordr(id, name) VALUES(6,'FR'); ``` ```sql SAVEPOINT fr; ``` ```sql INSERT INTO ordr(id, name) VALUES(7,'RU'); ``` ```sql SAVEPOINT ru; ``` ```sql INSERT INTO ordr(id, name) VALUES(8,'CA'); ``` ```sql SAVEPOINT ca; ``` -------------------------------- ### Install Go MySQL Driver using go get Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/200.quickstart/300.create-sample-application-of-mysql-mode/400.golang-application-of-mysql-model.md Install the Go MySQL Driver using the `go get` command. This method is suitable for Go versions 1.13 to 1.16. ```bash go get -u github.com/go-sql-driver/mysql ``` -------------------------------- ### Create Tables for Examples Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/500.sql-reference/100.sql-syntax/300.common-tenant-of-oracle-mode/900.sql-statement-of-oracle-mode/200.dml-of-oracle-mode/500.select-of-oracle-mode/200.collection-select-of-oracle-mode.md Sets up two tables, tbl1 and tbl2, with integer columns for demonstrating set-based SELECT operations. ```sql obclient> CREATE TABLE tbl1 (col1 INT, col2 INT); Query OK, 0 rows affected obclient> CREATE TABLE tbl2 (col1 INT, col2 INT); Query OK, 0 rows affected obclient> INSERT INTO tbl1 VALUES (1, 1), (2, 2),(2,2); Query OK, 3 rows affected Records: 3 Duplicates: 0 Warnings: 0 obclient> INSERT INTO tbl2 VALUES (2, 2),(2, 2),(3,3); Query OK, 3 rows affected Records: 3 Duplicates: 0 Warnings: 0 obclient> SELECT * FROM tbl1; +------+------+ | COL1 | COL2 | +------+------+ | 1 | 1 | | 2 | 2 | | 2 | 2 | +------+------+ 3 rows in set obclient> SELECT * FROM tbl2; +------+------+ | COL1 | COL2 | +------+------+ | 2 | 2 | | 2 | 2 | | 3 | 3 | +------+------+ 3 rows in set ``` -------------------------------- ### Example: Refresh IO Calibration for All OBServers (Default) Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/600.manage/200.tenant-management/600.common-tenant-operations/300.resource-isolation/300.resource-isolation-of-mysql-mode/150.disk-performance-calibration-of-mysql-mode.md This example demonstrates refreshing disk performance information for all OBServer nodes in the cluster using default settings. ```sql ALTER SYSTEM REFRESH IO CALIBRATION; ``` -------------------------------- ### Continue Plugin Model Configuration Example Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/680.ecological-integration/1100.AI/1100.continue.md Example JSON configuration for the Continue IDE plugin to connect to a local AI model. ```json name: Local Assistant version: 1.0.0 schema: v1 models: # 模型名称 - name: DeepSeek-R1-671B # 模型厂商 provider: deepseek # 模型类型 model: DeepSeek-R1-671B # 模型访问的 URL 地址 apiBase: "********* # 模型访问的 API 密钥 apiKey: "******** # 上下文提供者 context: - provider: code - provider: docs - provider: diff - provider: terminal - provider: problems - provider: folder - provider: codebase ``` -------------------------------- ### Example Table Definition Output Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/800.configuration-items-and-system-variables/100.system-configuration-items/400.tenant-level-configuration-items/2150.default_table_organization.md This is an example of the output from `SHOW CREATE TABLE`, illustrating the detailed configuration of a table, including its organization, character set, and compression settings. ```shell +-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | test_tbl1 | CREATE TABLE `test_tbl1` ( `col1` int(11) DEFAULT NULL ) ORGANIZATION HEAP DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE ENABLE_MACRO_BLOCK_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 | +-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set ``` -------------------------------- ### Install NTP Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/400.deploy/500.deploy-oceanbase-database-community-edition/200.local-deployment/200.environment-and-configuration-checks/300.configure-the-clock-source-optional.md Install NTP and ntpdate packages on each machine in the cluster. This is the first step in setting up NTP synchronization. ```shell [root@test002 ~]# yum install ntp ntpdate -y ``` -------------------------------- ### Example: Marking Multiple Savepoints in a Transaction Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/300.develop/200.application-development-of-oracle-mode/600.transaction-in-develop-of-oracle-mode/300.transaction-savepoints-of-oracle-mode/100.mark-a-savepoint-of-oracle-mode.md This example demonstrates starting a transaction, inserting data, and marking multiple savepoints (`fr`, `ru`, `ca`) within that transaction. Ensure autocommit is disabled before starting the transaction. ```sql obclient [SYS]> SET session autocommit=off; Query OK, 0 rows affected obclient [SYS]> BEGIN; Query OK, 0 rows affected obclient [SYS]> INSERT INTO ordr(id, name) VALUES(6,'FR'); Query OK, 1 row affected obclient [SYS]> SAVEPOINT fr; Query OK, 0 rows affected obclient [SYS]> INSERT INTO ordr(id, name) VALUES(7,'RU'); Query OK, 1 row affected obclient [SYS]> SAVEPOINT ru; Query OK, 0 rows affected obclient [SYS]> INSERT INTO ordr(id, name) VALUES(8,'CA'); Query OK, 1 row affected obclient [SYS]> SAVEPOINT ca; Query OK, 0 rows affected ``` -------------------------------- ### Example: Clear Disk Performance Information Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/600.manage/200.tenant-management/600.common-tenant-operations/300.resource-isolation/300.resource-isolation-of-mysql-mode/150.disk-performance-calibration-of-mysql-mode.md This example shows how to clear all disk performance calibration data from OBServer nodes in the cluster. ```sql ALTER SYSTEM REFRESH IO CALIBRATION CALIBRATION_INFO = (""'); ``` -------------------------------- ### Create a HASH-partitioned table and a local index Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/300.database-object-management/100.manage-object-of-mysql-mode/300.manage-partitions-of-mysql-mode/900.create-partition-table-index-of-mysql-mode/200.local-index-of-mysql-mode.md This example demonstrates creating a HASH-partitioned table and then adding a local index to it. The `LOCAL` keyword explicitly defines it as a local index. ```sql obclient> CREATE TABLE tbl1_h(col1 INT PRIMARY KEY,col2 INT) PARTITION BY HASH(col1) PARTITIONS 5; Query OK, 0 rows affected obclient> CREATE INDEX tbl1_h_idx1 ON tbl1_h(col2) LOCAL; Query OK, 0 rows affected ``` -------------------------------- ### Complete Example: Procedure DDL Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/700.reference/600.pl-reference/300.pl-oracle/1400.pl-system-package-oracle/9900.dbms-metadata-oracle/200.get-ddl-oracle.md This example demonstrates creating a procedure and then using GET_DDL to retrieve its DDL statement. ```APIDOC ## Complete Example 2: Procedure DDL ### Create Procedure ```sql create procedure tEst1(tEst1 int, "nAMe" varchar2, age float) as begin null; end; / ``` ### Retrieve DDL ```sql -- Enable server output to display messages in the SQL command-line interface. set serveroutput on; -- Call the DBMS_METADATA.GET_DDL function to retrieve the DDL statement for the procedure named 'TEST1'. call dbms_output.put_line(dbms_metadata.get_ddl('PROCEDURE','TEST1')); ``` ### Expected Output ```shell CREATE OR REPLACE PROCEDURE "SYS"."TEST1" ( "TEST1" IN int, "nAMe" IN varchar2, "AGE" IN float ) IS begin null; end ``` ``` -------------------------------- ### Example of Initializing OceanBase Database Directories Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/600.manage/100.cluster-management/300.common-cluster-operations/400.add-a-node.md An example demonstrating the creation and linking of OceanBase Database directories for a cluster named 'obdemo'. ```shell [root@xxx admin]#su - admin -bash-4.2$ mkdir -p /data/1/obdemo/{etc3,sort_dir,sstable,slog} -bash-4.2$ mkdir -p /data/log1/obdemo/{clog,etc2,ilog,oob_clog} -bash-4.2$ mkdir -p /home/admin/oceanbase/store/obdemo -bash-4.2$ for t in {etc3,sort_dir,sstable,slog};do ln -s /data/1/obdemo/$t /home/admin/oceanbase/store/obdemo/$t; done -bash-4.2$ for t in {clog,etc2,ilog,oob_clog};do ln -s /data/log1/obdemo/$t /home/admin/oceanbase/store/obdemo/$t; done ``` -------------------------------- ### Example: Creating User, Granting Privileges, and Killing a Session Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/500.sql-reference/100.sql-syntax/300.common-tenant-of-oracle-mode/900.sql-statement-of-oracle-mode/300.dcl-of-oracle-mode/150.alter-system-kill-session.md This example demonstrates creating a user, granting necessary privileges, viewing active sessions, and then terminating a specific session using its ID. ```sql obclient [SYS]> CREATE USER kill_user IDENTIFIED BY killuser123; Query OK, 0 rows affected obclient [SYS]> GRANT CREATE SESSION TO kill_user; Query OK, 0 rows affected obclient [SYS]> GRANT ALTER SYSTEM TO kill_user; Query OK, 0 rows affected 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 | | 3221487722 | SYS | 100.xx.xxx.xxx:40025 | SYS | Sleep | 93 | SLEEP | NULL | +------------+-----------+----------------------+-----------+---------+------+--------+------------------+ 1 row in set obclient [KILL_USER]> ALTER SYSTEM KILL SESSION '3221487726'; Query OK, 0 rows affected ``` -------------------------------- ### Install OceanBase MCP Server Dependencies Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/680.ecological-integration/1100.AI/1100.continue.md Navigate to the mcp-oceanbase directory, create a virtual environment using uv, activate it, and install the project dependencies. ```shell cd mcp-oceanbase uv venv source .venv/bin/activate uv pip install . ``` -------------------------------- ### Create Client and Get OceanBase Info in Go Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/1500.Components-and-Tools/100.manage/100.obshell/500.obshell-sdk-reference/200.go/200.cluster-management/1800.get-oceanbase-info-of-go.md Demonstrates creating a client instance with connection details and password, then fetching OceanBase cluster information. Ensure obshell is running and handle errors appropriately in production. ```go package main import ( "github.com/oceanbase/obshell-sdk-go/services" ) func main() { var err error // Handle errors in the production environment. // Create a client instance, with the IP address of "10.10.10.1" and the port number of 2886. // Enter the root@sys password "****" for the cluster. client, err := services.NewClientWithPassword("10.10.10.1", 2886, "***") // Obtain the information about the OceanBase cluster. obInfo, err := client.V1().GetObInfo() } ``` -------------------------------- ### Create and Insert Data for CASE Examples Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/300.develop/100.application-development-of-mysql-mode/500.read-data-of-mysql-mode/300.use-operators-and-functions-in-query-of-mysql-mode/900.use-the-case-function-in-a-query-of-mysql-mode.md Sets up two tables, `t_case` and `t_case2`, with sample data to demonstrate the CASE function in subsequent queries. ```sql obclient> CREATE TABLE t_case(id NUMBER NOT NULL PRIMARY KEY, abbr VARCHAR(5)); Query OK, 0 rows affected obclient> INSERT INTO t_case(id, abbr) VALUES (1,'US'),(2,'UK'),(3,'CN'),(4,'JP'); Query OK, 4 rows affected Records: 4 Duplicates: 0 Warnings: 0 obclient> CREATE TABLE t_case2(id NUMBER NOT NULL PRIMARY KEY, c_date DATE ); Query OK, 0 rows affected obclient> INSERT INTO t_case2(id,c_date) VALUES (1,'2021-03-01'),(2,'2021-05-08'),(3,'2021-07-07'),(4,'2021-10-11'),(5,'2021-12-12'),(6,'2022-01-05'); Query OK, 6 rows affected Records: 6 Duplicates: 0 Warnings: 0 ``` -------------------------------- ### Start a specific zone and verify status Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/600.manage/100.cluster-management/300.common-cluster-operations/800.add-a-zone.md Example of starting 'zone4' and then querying DBA_OB_ZONES to confirm its status has changed to ACTIVE. ```sql obclient [(none)]> ALTER SYSTEM START ZONE zone4; Query OK, 0 rows affected obclient [(none)]> SELECT * FROM oceanbase.DBA_OB_ZONES; ``` -------------------------------- ### Example Server List Output Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/zh-CN/400.deploy/300.deploy-oceanbase-enterprise-edition/400.deploy-through-the-command-line/100.configure-a-deployment-environment-command-line/100.initializing-the-observer-server-using-oatcli.md This is an example of the output returned when querying for server information. It includes server ID, IP address, SSH port, IDC information, description, and operational status. ```shell 14:35:50 [DEBUG] Starting new HTTP connection (1): xxx.xxx.xxx.1:7000 14:35:50 [DEBUG] http://xxx.xxx.xxx.1:7000 "GET /api/v2/servers HTTP/1.1" 200 1085 ┏━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓ ┃ id ┃ ip ``` -------------------------------- ### Request Example for Querying Tenant Parameter Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/1500.Components-and-Tools/100.manage/100.obshell/400.obshell-api-reference/500.tenant-management/1800.query-tenant-configuration-items.md This example shows the GET request URI to query a specific tenant parameter. ```bash GET 10.10.10.1:2886/api/v1/tenant/t1/parameter/max_partition_num ``` -------------------------------- ### Example: Activate 'role1' for 'test' User Login Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/600.manage/500.security-and-permissions/300.access-control/200.user-and-permission/300.permission-of-oracle-mode/400.manage-roles-of-oracle-mode/500.specify-an-active-or-inactive-role-for-the-user-of-oracle-mode.md This is a practical example demonstrating how to activate the 'role1' for the user 'test' upon their login. The user 'test' will have the privileges of 'role1' after this command is executed and they log in. ```sql obclient>ALTER USER test DEFAULT ROLE role1; ``` -------------------------------- ### Install Go-SQL-Driver/MySQL using go get Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/300.develop/100.application-development-of-mysql-mode/200.sample-program-of-mysql-mode/400.go-of-mysql-mode/1.go-sql-driver-mysql-connection-oceanbase-sample-program.md Use this command to install or update the Go-SQL-Driver/MySQL package. Ensure you are in your project directory. ```shell C:\Users\admin\Desktop\go-oceanbase>go get -u github.com/go-sql-driver/mysql go: downloading github.com/go-sql-driver/mysql v1.7.1 go: added github.com/go-sql-driver/mysql v1.7.1 ``` -------------------------------- ### Show Tenant Creation Configuration Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/1100.performance-test/200.sysbench-benchmark-testing-on-oceanbase-database/400.oceanbase-sysbench-performance-issue-analysis.md Display the exact command used to create a tenant, including resource allocations like cpu_count. This is crucial for diagnosing CPU under-allocation issues. ```sql show create tenant xxx; ``` -------------------------------- ### Start obshell Agent Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/1500.Components-and-Tools/100.manage/100.obshell/210.use-case/200.cluster-management/200.deploy-oceanbase-cluster.md Starts the obshell agent on a specific OBServer node. Ensure the installation directory is correct and the port is accessible. ```shell [admin@test001 ~]$ /home/admin/oceanbase/bin/obshell agent start --ip 10.10.10.1 -P 2886 ``` ```shell [admin@test002 ~]$ /home/admin/oceanbase/bin/obshell agent start --ip 10.10.10.2 -P 2886 ``` ```shell [admin@test003 ~]$ /home/admin/oceanbase/bin/obshell agent start --ip 10.10.10.3 -P 2886 ``` -------------------------------- ### Create Maven Project Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/680.ecological-integration/1100.AI/800.springai.md Use this command to generate a new Maven project with a quickstart archetype. Ensure you are in the desired parent directory before execution. ```shell mvn archetype:generate -DgroupId=com.alibaba.cloud.ai.example -DartifactId=vector-oceanbase-example -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false ``` -------------------------------- ### Start All Observer Processes (Go) Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/1500.Components-and-Tools/100.manage/100.obshell/210.use-case/200.cluster-management/310.start-oceanbase-cluster.md Execute a cluster-wide start command with the obshell-sdk-go. Ensure proper client creation and request setup. ```go ··· client, err := services.NewClientWithPassword("10.10.10.1", 2886, "****") req := client.V1().NewStartRequest(v1.SCOPE_GLOBAL) dag, err := client.V1().StartSyncWithRequest(req) # Call /api/v1/ob/start. ··· ``` -------------------------------- ### Example of SHOW CREATE PROCEDURE Source: https://github.com/oceanbase/oceanbase-doc/blob/V4.3.5/en-US/700.reference/600.pl-reference/200.pl-mysql/700.pl-database-management-statements-mysql/200.show-create-procedure-mysql.md This example demonstrates how to call the SHOW CREATE PROCEDURE statement and shows a sample return result. ```sql obclient> SHOW CREATE PROCEDURE proc_name; ``` ```shell +-------------+----------+-----------------+-----------------------+----------------------+--------------------+ | Procedure | sql_mode | Create Procedure | character_set_client | collation_connection | Database Collation | +----------+----------+-----------------+-----------------------+----------------------+-----------------------+ | proc_name | STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE |CREATE PROCEDURE `test`.`proc_name`() BEGIN DECLARE var_name VARCHAR(20) DEFAULT 'ZhangSan'; SET var_name = 'LiSi'; SELECT var_name; END | utf8mb4 | utf8mb4_general_ci | utf8mb4_general_ci | +----------+----------+-----------------+-----------------------+----------------------+-----------------------+ 1 row in set ```