MySql : Understanding Generated Columns
The Theory Generated Columns is a feature released on MySQL 5.7. They can be used during CREATE TABLE or ALTER TABLE statements. It is a way of storing data without actually sending it through the INSERT or UPDATE clauses in SQL. The database resolves what the data will be. There are two types of Generated Columns: Virtual and Stored. They work with: mathematical expressions (product_price * quantity)built-in functions (RIGHT(), CONCAT(), FROM_UNIXTIME(), JSON_EXTRACT())literals (“2”, “new”, 0) Besides that, they can be indexed but they don’t allow subqueries in it.A Generated Column works within the table domain. If you need subqueries on a particular column, you may have to look at Views. The basic example As an example I am going to use an e-commerce database as based on my past experience…