OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.2.5

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.2.5
    iconOceanBase Database
    SQL - V 4.2.5
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    SQL
    KV
    • V 4.6.0
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Data type conversion behavior in MySQL tenants in strict mode

    Last Updated:2026-04-09 09:38:52  Updated
    Share
    What is on this page
    Core differences
    Behavior when strict mode is ON
    DML statements
    SELECT statements
    Behavior when strict mode is OFF
    DML statements
    SELECT statements
    Important considerations
    STRICT_TRANS_TABLES vs. STRICT_ALL_TABLES
    Implicit conversion rules
    Explicit conversion
    Other modes
    Troubleshooting

    folded

    Share

    When the sql_mode parameter is set to strict mode (by specifying STRICT_TRANS_TABLES or STRICT_ALL_TABLES), data type conversion failures during DML statements (such as INSERT, UPDATE, REPLACE, and DELETE) and SELECT statements are handled differently.

    Core differences

    Statement type
    Strict mode OFF
    Strict mode ON
    Design philosophy
    DML statements
    (INSERT, UPDATE, DELETE, etc.)
    The statement is executed successfully.
    Failed data is filled with the default value 0.
    A warning is output.
    The statement is failed.
    The entire statement is rolled back.
    If the DML statement contains a SELECT subquery, the type conversion in the SELECT subquery also follows the strict mode restrictions.
    Prioritizes data consistency.
    Strict mode rejects risky data conversions.
    Ensures data integrity and transaction security.
    SELECT statements
    (query operations)
    The statement continues to execute.
    A warning is generated.
    Part of the results are returned or the conversion is attempted.
    The statement continues to execute.
    A warning is generated.
    Part of the results are returned or the conversion is attempted.
    Focuses on data query operations.
    Prioritizes query availability.
    Warns about potential issues.

    Behavior when strict mode is ON

    DML statements

    When sql_mode is set to strict mode, DML statements are immediately terminated upon encountering a data type conversion failure.

    Behavior characteristics:

    • The statement execution fails, and a clear error message is returned.
    • All modifications made by the statement are rolled back.
    • Data is not partially updated or inserted as data that does not match the target column type.

    Examples:

    INSERT INTO t (int_col) VALUES ('abc');
    -- The string 'abc' cannot be converted to an integer, and an error is returned.
    
    UPDATE t SET date_col = '2024-02-30';
    -- '2024-02-30' is an invalid date (February does not have 30 days), and an error is returned.
    
    INSERT INTO t (varchar10_col) VALUES ('This string is way too long');
    -- The string length exceeds the VARCHAR(10) definition, and an error is returned.
    

    Principle: DML operations directly modify persistent data. Strict mode ensures data accuracy and consistency. Allowing incorrect type conversions can lead to data corruption or violations of business logic, so OceanBase Database chooses to fail and roll back when risky conversions occur.

    SELECT statements

    When sql_mode is set to strict mode, SELECT statements are more lenient in handling data type conversion failures compared to DML statements.

    Behavior characteristics:

    • The statement execution does not fail due to type conversion failures.
    • Failed conversion values are treated as NULL or default values.
    • A warning is generated, which can be viewed using SHOW WARNINGS;.
    • The query continues to execute and returns the result set.

    Examples:

    SELECT * FROM t WHERE int_col = 'abc';
    -- 'abc' cannot be converted to an integer, a warning is generated, and it may be treated as 0 or NULL.
    
    SELECT DATE_ADD('2024-02-30', INTERVAL 1 DAY);
    -- An invalid date, a warning is generated, and the function returns NULL.
    
    SELECT CAST('abc' AS UNSIGNED);
    -- Attempting to convert a string to an unsigned integer, a warning is generated, and 0 is returned.
    

    Principle: SELECT is a query operation that does not modify persistent data. Its main goal is to return as much result data as possible for user inspection. Strict mode focuses more on other aspects (such as ONLY_FULL_GROUP_BY) in SELECT and tends to prioritize flexibility and partial result availability for type conversion failures.

    Behavior when strict mode is OFF

    DML statements

    In non-strict mode, DML statements continue to execute upon encountering a type conversion failure.

    Behavior characteristics:

    • The statement execution succeeds, and a warning is output.
    • The failed conversion data is replaced with the default value of the corresponding type (0).
    • Data is written to the table.

    Examples:

    CREATE TABLE test(a INT, b INT);
    INSERT INTO test VALUES('abc', 'abc');
    SELECT * FROM test;
    

    Execution result:

    +------+------+
    | a    | b    |
    +------+------+
    |    0 |    0 |
    +------+------+
    1 row in set (0.039 sec)
    

    SELECT statements

    In non-strict mode, SELECT statements behave similarly to when strict mode is ON, generating warnings and continuing to execute.

    Important considerations

    STRICT_TRANS_TABLES vs. STRICT_ALL_TABLES

    In MySQL, these two modes behave similarly in DML statements for type conversion failures (both return errors). The main difference lies in how they handle non-transactional tables (such as MyISAM). Since OceanBase Database's underlying transaction engine does not differ across different sql_mode settings, STRICT_TRANS_TABLES and STRICT_ALL_TABLES typically behave the same in MySQL tenants of OceanBase Database regarding type conversion failures.

    Implicit conversion rules

    Even without conversion failures, implicit conversions can lead to precision loss or semantic changes. Strict mode does not block all implicit conversions but mainly prevents those that are completely unconvertible or result in complete data loss/invalidity (such as failed string-to-number conversion, invalid dates, or inserting excessively long strings).

    Explicit conversion

    When using the CAST() function for explicit conversion, if the conversion fails, NULL is returned, and a warning is generated, regardless of the statement type or sql_mode setting. This is standard SQL behavior.

    Other modes

    Strict mode is often used in conjunction with other modes like ERROR_FOR_DIVISION_BY_ZERO. These modes affect how specific errors, such as division by zero or invalid dates, are handled.

    Troubleshooting

    • Error (ERROR) vs. warning (WARNING): If the client returns ERROR, the DML statement has completely failed. If a result set is returned but a warning exists, it indicates a conversion issue in the SELECT statement.

    • Check sql_mode: Use SELECT @@sql_mode; to confirm if strict mode is enabled.

    • View execution plans and logs: For complex scenarios, OceanBase Database's execution plan output (EXPLAIN) can provide more detailed insights.

    Previous topic

    Reserved keywords (Oracle mode)
    Last

    Next topic

    Overview
    Next
    What is on this page
    Core differences
    Behavior when strict mode is ON
    DML statements
    SELECT statements
    Behavior when strict mode is OFF
    DML statements
    SELECT statements
    Important considerations
    STRICT_TRANS_TABLES vs. STRICT_ALL_TABLES
    Implicit conversion rules
    Explicit conversion
    Other modes
    Troubleshooting