OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Developer Center

V4.5.0
  • Topics Overview
  • Overview
    • What is ODC?
    • Features
    • Architecture
    • Limitations
    • ODC console
  • Quick Start
    • Client ODC
      • Overview
      • Install Client ODC
      • Use Client ODC
    • Web ODC
      • Overview
      • Deploy Web ODC
      • Use Web ODC
  • Data Source Management
    • Create a data source
    • Data sources and project collaboration
    • Database O&M
      • Session management
      • Global variable management
      • Recycle bin management
  • SQL Development
    • Edit and execute SQL statements
    • Perform PL compilation and debugging
    • Use the command-line window
    • Edit and export the result set
    • Execution Analysis
    • Generate test data
    • System settings
    • Intelligent SQL development
    • Common features
    • Database objects
      • Table objects
        • Overview
        • Create a table
      • View objects
        • Overview
        • Create a view
        • Manage views
      • Materialized view objects
        • Overview
        • Create a materialized view
        • Manage materialized views
      • Function objects
        • Overview
        • Create a function
        • Manage functions
      • Stored procedure objects
        • Overview
        • Create a stored procedure
        • Manage stored procedures
      • Sequence objects
        • Overview
        • Create a sequence
        • Manage sequences
      • Package objects
        • Overview
        • Create a program package
        • Manage program packages
      • Trigger objects
        • Overview
        • Create a trigger
        • Manage triggers
      • Type objects
        • Overview
        • Create a type
        • Manage types
      • Synonym objects
        • Overview
        • Create a synonym
        • Manage synonyms
      • External resource objects
        • External resources
        • Create an external resource
        • Manage external resources
  • Database Change Risk Management
    • Project collaborative management
      • Project management
      • Manage databases
      • Manage logical databases
      • Add object storage files
      • Manage project members
      • Desensitize data
      • Notification management
        • Overview
        • View notification records
        • Manage notification channels
          • Create a notification channel
          • View, edit, and delete a notification channel
          • Configure a custom channel
        • Manage notification rules
    • Manage user permissions
      • Users and roles
      • Automatic authorization
      • Apply for project permissions
      • Apply for database permissions
      • Apply table/view permissions
    • Security standards
      • Environment configuration
        • SQL check specifications
        • SQL window specification
      • Risk Management
        • Overview
        • Manage risk identification rules
        • Manage approval processes
      • Desensitization algorithms
      • Operation audit
  • Ticket Management
    • Import schemas and data
    • Export schemas and data
    • Database change management
    • Manage changes to logical databases
    • Batch database change management
    • Online schema changes
    • Synchronize shadow tables
    • Schema comparison
  • Data Lifecycle Management
    • Data archiving
    • Data cleanup
    • Manage partitioning plans
      • Manage partitioning plans
      • Set partitioning strategies
      • Examples of partitioning strategies
    • SQL Plan
  • System Integration
    • Login integration
    • Approval integration
    • SQL approval integration
    • Bastion host integration
    • Integrate with LLMs
  • Deployment Guide
    • Deployment overview
    • Preparations before deployment
    • Deploy ODC in single-node mode
    • Deploy ODC in high-availability mode
    • Deployment verification
  • Upgrade Guide
    • Upgrade Overview
    • Preparations for upgrade
    • Update single-node ODC
    • Update high-avaliability ODC
    • Upgrade verification
    • Rollback after upgrade failed
  • Best Practices
    • Tips for SQL development
    • Explore ODC team workspaces
    • Understanding real-time SQL diagnostics for OceanBase AP
    • OceanBase historical database solutions
    • ODC SQL check for automatic identification of high-risk operations
    • Integration with ODC enterprise-level account system
    • Manage and modify sharded databases and tables via ODC
    • Data masking and control practices
    • Enterprise-level control and collaboration: Safeguard every database change
  • Troubleshooting
    • ODC troubleshooting process
    • Collect message
      • View the runtime environment and version information
      • View web ODC logs
      • View client ODC logs
      • View end-to-end ODC-related logs
      • View ODC MetaDB data
      • Query the index status in OceanBase Database V4.x
      • Query the index status in OceanBase Database V1.4.x to V3.2.x
      • Collect JVM runtime information
      • Use tcpdump to capture packets
    • FAQ
      • Installation of client ODC
      • Web ODC deployment and startup
      • Connection Information
      • Command-line window
      • DDL statement display
  • Release Notes
    • V4.5
      • ODC V4.5.0
    • V4.4
      • ODC V4.4.0
      • ODC V4.4.1
      • ODC V4.4.2
      • ODC V4.4.3
    • V4.3
      • ODC V4.3.4
      • ODC V4.3.3
      • ODC V4.3.2
      • ODC V4.3.1
      • ODC V4.3.0
    • V4.2
      • ODC V4.2.4
      • ODC V4.2.3
      • ODC V4.2.2
      • ODC V4.2.1
      • ODC V4.2.0
    • V4.1
      • ODC V4.1.3
      • ODC V4.1.2
      • ODC V4.1.1
      • ODC V4.1.0
    • V4.0
      • ODC V4.0.2
      • ODC V4.0.0
    • V3.4
      • ODC V3.4.0
    • V3.3
      • ODC V3.3.3
      • ODC V3.3.2
      • ODC V3.3.1
      • ODC V3.3.0
    • V3.2
      • ODC V3.2.3
      • ODC V3.2.2
      • ODC V3.2.1
      • ODC V3.2.0

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Developer Center
  3. V4.5.0

Edit and execute SQL statements

Last Updated:2026-09-03 09:11:30

Background information
Prerequisites
Edit SQL statements
SQL Intelligent Editor
SQL Auto-completion
Execute SQL statements
View data
SQL scripts
Save a script
Manage scripts
Snippets
Create a snippet
Manage snippets
References

This topic describes how to edit and execute SQL statements in the SQL window.

Background information

The SQL window of ODC provides a GUI for data processing. You can sort, filter, add, edit, and delete data, and execute database objects in the SQL window.

The following example describes how to create a table named employee in the odc_test database in the SQL window.

Note

All data in this example is for reference only. You can replace the data as needed.

Prerequisites

You have queried, exported, or modified the database.

Note

If you do not have the database permissions, you can go to Tickets > Database Permissions to apply for the corresponding query/export/modify permissions.

Edit SQL statements

  1. Click the name of the odc_test project, test_data, to go to the SQL window.

    1

  2. In the SQL window, enter SQL statements to create a table named employee.

    2

    CREATE TABLE test_data.employee (emp_no int(120) COMMENT 'Employee ID' NOT NULL, birthday date COMMENT 'Birthday' NULL,name varchar(120) COMMENT 'Employee name' NULL,CONSTRAINT cons_employee_empno PRIMARY KEY (emp_no)) DEFAULT CHARSET = utf8mb4    COLLATE = utf8mb4_general_ci;
    

    The syntax is as follows:

    CREATE TABLE table_name (column_name column_type, column_name column_type,.......);
    

    The following table describes the parameters.

    Parameter
    Description
    CREATE TABLE The statement that creates a table with a specified name. You must have the privilege to create tables.
    table_name The name of the table. The table name must conform to the identifier naming rules.
    column_name column_type The name and data type of each column in the table. Separate the tuples of multiple columns with commas (,).
    • You can click the name of a database in the SQL window to switch to the database.

      3

    • For more information about the toolbar in the SQL window, see Common features.

SQL Intelligent Editor

In the SQL editing area, after you select the content to edit, you can perform quick intelligent operations by using the editing buttons on the right or the shortcut menu. These operations include SQL generation, SQL correction, SQL rewriting, and SQL optimization. For more information about these operations, see Intelligent SQL Development.

SQL Auto-completion

The ODC SQL window supports intelligent auto-completion. When you enter an SQL statement, the system automatically suggests possible completion options, including table names, column names, function names, and keywords.

Auto-completion supports the following object types:

Object Type
Description
Table A table object in the database.
View A view object in the database.
Column A field column in a table or view.
Function A function in the database.
Stored Procedure A stored procedure in the database.
Trigger A trigger in the database.
Sequence A sequence in the database.
Synonym A synonym in the database.
Type A type object in the database.
Package A package object in the database (Oracle-compatible mode).
Index An index object in the database.

Note

The auto-completion feature intelligently filters completable objects based on the data source type of your current connection and the current context.

Execute SQL statements

  1. After you write SQL statements, click Run F8 in the toolbar to run all SQL statements in the current SQL window.

    Feature
    Description
    Run F8 Click this option to run all SQL statements in the current SQL window. You can also press F8 to run all SQL statements.
    Run Current Statement (F9) Click this option to run all selected SQL statements or the statement in the line where the pointer is located. You can also press Ctrl+Enter (Windows) or Command+Enter (MacOS) to run the current statement.
    Abort Click this option to abort the statement that is being executed.

    4

  2. On the result tabs, view the status and results of statement execution.

    5

View data

  1. In the left-side navigation pane of the SQL window, verify that the employee table exists in the database icon.

    odc_test > test_data > table > employee
    

    6

    • Enter a keyword in the search box, or press the shortcut key Ctrl+J (Windows) / Command+J (MacOS) to open the search drop-down list and enter a keyword. You can search for all objects such as databases, tables, views, and functions in the current project or data source.

      7

  2. You can group databases by different conditions.

    8

  3. Click to manually synchronize metadata of tables and columns in the current project or data source.

  4. Right-click the employee table or edit a SELECT statement in the SQL window to view the table data.

    9

  5. Right-click the name of the database and select Sync Metadata to manually synchronize metadata of tables and columns in the database.

    10

SQL scripts

ODC allows you to save and edit scripts in an SQL window or an anonymous block window. You can also manage the saved scripts on the script tabs.

Save a script

Save the script that creates the employee table in an SQL window.

Parameter
Example value
Table name employee
Script name create_employee
  1. In the SQL window, click the Save Script icon on the toolbar.

    11

  2. Specify the script name and click OK.

    12

Manage scripts

  1. In the left-side navigation pane of the SQL window, click script to go to the script management page.

    13

  2. On the Script page, you can edit, download, or delete saved scripts, copy the path of a script, and upload a script from your local disk.

    You can double-click a script name to directly reference the script content in the SQL window. You can also copy the path to reference the script content in the command line window.

    14

    When you download a script, you can select multiple scripts for batch download.

    Note

    You can download up to 200 scripts in a batch.

    1. Click the name of the script that you want to download.

    2. Use the ctrl (Windows) or command (MacOS) key together with left mouse button to select more scripts, or use the shift key together with left mouse button to select scripts in a range.

      18

    3. Right-click to select Download in bulk.

Snippets

ODC allows you to create snippets. You can query and view the usage of related statements in the snippets during development.

Create a snippet

Save the snippet that creates the employee table on the snippets page.

Parameter
Example value
Table name employee
Snippet name create_table
  1. In the left-side navigation pane of the SQL window, click script and click + to create a snippet on the code snippets tab.

    15

  2. On the Create Code Segment page, specify the snippet information and click OK.

    16

    Note

    In ODC V4.2.3 and later, the maximum length of a snippet is 64 KB.

Manage snippets

On the snippets page, you can copy, edit, delete, and refresh saved snippets.

17

References

  • Compile and debug PL programs

  • Command-line window

  • Edit and export the result set

  • Execution analysis

  • Generate test data

  • Database change management

  • Manage partitioning plans

  • Synchronize shadow tables

  • Online schema changes

Previous topic

Recycle bin management
Last

Next topic

Perform PL compilation and debugging
Next
on this page
Background information
Prerequisites
Edit SQL statements
SQL Intelligent Editor
SQL Auto-completion
Execute SQL statements
View data
SQL scripts
Save a script
Manage scripts
Snippets
Create a snippet
Manage snippets
References