Comments - Generated (Virtual and Persistent/Stored) Columns

9 years, 5 months ago Olivier Bertrand

"A virtual column is a column in a table that has its value automatically calculated using either a deterministic expression, or the values of other fields in the table."

This seems to say that it is possible to use an expression that does not refer to other fields in the tables. However, to my knowledge, such an expression is either not deterministic or constant. In both cases it is rejected by MariaDB.

By the way, I don't understand why constant expressions could not be accepted.

 
9 years, 5 months ago Ian Gilfillan

Thanks, the wording is incorrect and will be changed. I'm also unsure as to why constants are not accepted!

 
8 years, 8 months ago Jan Steinman

By the way, I don't understand why constant expressions could not be accepted.

They apparently work in 10.1.6:

ALTER TABLE `z_test` ADD `Const` INT(5)  AS (`ID` + 1) PERSISTENT AFTER `ID`;

MariaDB [EcoReality]> SELECT ID, Const from z_test;
+----+-------+
| ID | Const |
+----+-------+
|  1 |     2 |
|  2 |     3 |
|  3 |     4 |
|  4 |     5 |
+----+-------+
4 rows in set (0.00 sec)
 
8 years, 8 months ago Jan Steinman

(I don't understand why this forum doesn't allow a bit of prettifying HTML...)-:

 
8 years, 8 months ago Ian Gilfillan

The editing help page gives details on formatting. I've tidied up your post above - there's lots you can do, just not HTML :)

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.