很可能在 MySQL 表中添加多個(gè)存儲(chǔ)的生成列。可以用以下示例來(lái)說(shuō)明:
示例
mysql> Create table profit1(cost int, price int, profit int AS (price-cost) STORED, price_revised int AS (price-2) STORED); Query OK, 0 rows affected (0.36 sec) mysql> Describe profit1; +---------------+---------+------+-----+---------+------------------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------+------+-----+---------+------------------+ | cost | int(11) | YES | | NULL | | | price | int(11) | YES | | NULL | | | profit | int(11) | YES | | NULL | STORED GENERATED | | price_revised | int(11) | YES | | NULL | STORED GENERATED | +---------------+---------+------+-----+---------+------------------+ 4 rows in set (0.00 sec) mysql> Insert into profit1(Cost, Price) values(100,110); Query OK, 1 row affected (0.09 sec) mysql> Insert into profit1(Cost, Price) values(200,220); Query OK, 1 row affected (0.09 sec) mysql> Select * from profit1; +------+-------+--------+---------------+ | cost | price | profit | price_revised | +------+-------+--------+---------------+ | 100 | 110 | 10 | 108 | | 200 | 220 | 20 | 218 | +------+-------+--------+---------------+ 2 rows in set (0.00 sec)
登錄后復(fù)制
以上就是我們?nèi)绾问褂?CREATE TABLE 語(yǔ)句在 MySQL 表中存儲(chǔ)多個(gè)生成列?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!