
- 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 MySQL stored GENERATED COLUMNS can work with mathematical expressions?
It can be illustrated with the help of an example in which we are creating a stored generated column in the table named ‘triangle_stored’. As we know that stored generated column can be generated by using the keyword ‘stored’.
Example
mysql> Create table triangle_stored(SideA DOUBLE, SideB DOUBLE, SideC DOUBLE AS (SQRT(SideA * SideB + SideB * SideB)) STORED); Query OK, 0 rows affected (0.47 sec) mysql> Describe triangle_stored; +-------+--------+------+-----+---------+------------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------+------+-----+---------+------------------+ | SideA | double | YES | | NULL | | | SideB | double | YES | | NULL | | | SideC | double | YES | | NULL | STORED GENERATED | +-------+--------+------+-----+---------+------------------+ 3 rows in set (0.00 sec) mysql> INSERT INTO triangle_stored(SideA, SideB) Values(1,1),(3,4),(6,8); Query OK, 3 rows affected (0.09 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> Select * from triangle_stored; +-------+-------+--------------------+ | SideA | SideB | SideC | +-------+-------+--------------------+ | 1 | 1 | 1.4142135623730951 | | 3 | 4 | 5.291502622129181 | | 6 | 8 | 10.583005244258363 | +-------+-------+--------------------+ 3 rows in set (0.00 sec)
- Related Articles
- How MySQL virtual GENERATED COLUMNS can work with mathematical expressions?
- How MySQL stored GENERATED COLUMNS can work with built-in functions?
- How Can MySQL virtual GENERATED COLUMNS work with built-in functions?
- How MySQL stored GENERATED COLUMNS are different from MySQL virtual GENERATED COLUMNS?
- How can we alter table to add MySQL stored GENERATED COLUMNS?
- How we have multiple stored GENERATED COLUMNS in MySQL table with CREATE TABLE statement?
- How can we alter table to add MySQL virtual GENERATED COLUMNS?
- How can we have multiple virtuals GENERATED COLUMNS in MySQL table with CREATE TABLE statement?
- Perform mathematical operations in a MySQL Stored Procedure?
- How can we say that Energy= Stored work?
- How can MySQL work with PHP programming language?
- Can we order a MySQL result with mathematical operations?\n
- What are the different types of MySQL GENERATED COLUMNS?
- How can I create MySQL stored procedure with IN parameter?
- How can I create MySQL stored procedure with OUT parameter?

Advertisements