In MySQL and compatible systems, VIRTUAL designates a generated column whose value is calculated from an expression every time the row is read. Unlike STORED generated columns, virtual columns do not occupy disk space because their value is not persisted. They can be indexed (with some limitations), used in queries, and referenced by other generated columns. A virtual column is always read only: you cannot insert or update it directly. Performance is generally slower than STORED columns because the expression is evaluated at query time. Virtual columns are ideal when the derived value changes rarely, storage conservation is important, or the expression is simple enough to compute quickly. They were first added in MySQL 5.7 and are also available in MariaDB and Oracle, though syntax details differ. PostgreSQL and SQLite achieve similar behavior with other constructs but do not use the VIRTUAL keyword.
MySQL 5.7
Virtual columns compute their value when you read the row, while stored columns persist the computed value on disk. Stored columns read faster but use more space.
No. A virtual column is read only. You must update the base columns referenced in its expression, and the virtual column value will adjust automatically.
No. You need to create an index explicitly, and only deterministic, non-JSON functions are allowed in expressions for indexing in most engines.
Inserts are slightly faster than with stored columns because nothing extra is written to disk, but the benefit is usually minor compared to overall workload.