
- 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
What are the different types of MySQL GENERATED COLUMNS?
We have two types of MYSQL generated columns as follows −
VIRTUAL GENERATED COLUMN
As the name suggests, this kind of generated column will not take any disk space. It can be generated with or without using the keyword ‘virtual’. To understand we are illustrating it in the following example −
Example
mysql> Create table triangle(SideA DOUBLE, SideB DOUBLE, SideC DOUBLE AS (SQRT(SideA * SideB + SideB * SideB))); Query OK, 0 rows affected (0.44 sec) mysql> Describe Triangle; +-------+--------+------+-----+---------+-------------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------+------+-----+---------+-------------------+ | SideA | double | YES | | NULL | | | SideB | double | YES | | NULL | | | SideC | double | YES | | NULL | VIRTUAL GENERATED | +-------+--------+------+-----+---------+-------------------+ 3 rows in set (0.00 sec)
The above description shows that the column SideC is a virtually generated column.
STORED GENERATED COLUMN
As the name suggests, this kind of generated column will take disk space. It can be generated by using the keyword ‘stored’. To understand we are illustrating it in the following example −
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)
The above description shows that the column SideC is a stored generated column.
- Related Articles
- How MySQL stored GENERATED COLUMNS are different from MySQL virtual GENERATED COLUMNS?
- What are the different types of psychotherapy?
- What are the different types of DBMS?
- What are the different types of ISDN?
- What are the Different Types of Marketing?
- What are the different types of Respiration?
- What are the different types of fabrics?
- What are the different types of motion?
- What are the different types of solutions?
- What are the different types of inflation?
- What Are the Different Types of Productivity?
- What are Different Types of Testing?
- What are different types of interrupts?
- What are different types of Respiration?
- What are different types of plant?

Advertisements