 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we alter table to add MySQL stored GENERATED COLUMNS?
For adding MySQL stored GENERATED COLUMNS in a table, we can use the same syntax as adding a column just adding “AS(expression)” after the data type. Its syntax would be as follows −
Syntax
ALTER TABLE table_name ADD COLUMN column_name AS(expression)STORED;
Example
mysql> ALTER TABLE employee_data_stored ADD COLUMN FULLName Varchar(200) AS (CONCAT_WS(" ", 'First_name','Last_name')) STORED; Query OK, 2 rows affected (1.23 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> Describe employee_data_stored; +------------+--------------+------+-----+---------+------------------+ | Field      | Type         | Null | Key | Default | Extra            | +------------+--------------+------+-----+---------+------------------+ | ID         | int(11)      | NO   | PRI | NULL    | auto_increment   | | First_name | varchar(50)  | NO   |     | NULL    |                  | | Last_name  | varchar(50)  | NO   |     | NULL    |                  | | FULL_NAME  | varchar(90)  | YES  |     | NULL    | STORED GENERATED | | FULLName   | varchar(200) | YES  |     | NULL    | STORED GENERATED | +------------+--------------+------+-----+---------+------------------+ 5 rows in set (0.00 sec)Advertisements
 