3

I have a table with a virtual field like this one:

CREATE TABLE `deleteme` (
    `number` int(11),
    `result` int(11) GENERATED ALWAYS AS (`number` + 1) STORED
)

How to get the expression from virtual field result?

`number` + 1

I would like avoid using SHOW CREATE TABLE to search for the string.

stramin
  • 2,183
  • 3
  • 29
  • 58

1 Answers1

3

You could query metadata tables:

SELECT column_name, generation_expression
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'deleteme';

db<>fiddle demo

Lukasz Szozda
  • 162,964
  • 23
  • 234
  • 275