How to get virtual expression in mysql?

69 views Asked by At

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.

1

There are 1 answers

0
Lukasz Szozda On BEST ANSWER

You could query metadata tables:

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

db<>fiddle demo