
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How Can MySQL CAST handle overflow?
MySQL CAST can handle overflow occurs during numerical expression assessment. Suppose if numeric expression evaluation produces overflow then MySQL reflects an error message. Now to handle this overflow we can change that numeric value to UNSIGNED with the help of CAST.
For example on adding 1 to BIGINT maximum value, MySQL produce an error due to overflow as follows −
mysql> Select 9223372036854775807 + 1; ERROR 1690 (22003): BIGINT value is out of range in '(9223372036854775807+1)'
Now, with the help of CAST, MySQL handles this kind of overflow as follows:
mysql> Select CAST(9223372036854775807 AS UNSIGNED) +1; +------------------------------------------+ | CAST(9223372036854775807 AS UNSIGNED) +1 | +------------------------------------------+ | 9223372036854775808 | +------------------------------------------+ 1 row in set (0.07 sec)
- Related Articles
- How Can MySQL exact-value arithmetic handle overflow?
- How does MySQL handle overflow during numeric expression assessment?
- How can MySQL handle the errors during trigger execution?
- How can we handle a result set inside MySQL stored procedure?
- MySQL CAST as DATE?
- MySQL - CAST DECIMAL to INT?
- How to cast DATETIME as a DATE in MySQL?
- How to cast from VARCHAR to INT in MySQL?
- How Can Project Managers Handle Project Dependencies?
- How Can Project Managers Handle Project Delays?
- How can we handle NULL values stored in a MySQL table by using PHP script?
- How do I cast a type to a BigInt in MySQL?
- How to use the CAST function in a MySQL SELECT statement?
- Can we cast reference variables in Java?
- How can YouTube handle boost your channel growth

Advertisements