顧名思義,臨時(shí)表是我們可以保存臨時(shí)數(shù)據(jù)的表。關(guān)于臨時(shí)表最重要的是,當(dāng)當(dāng)前客戶(hù)端會(huì)話(huà)終止時(shí)它們將被刪除。它可以在 CREATE 語(yǔ)句的幫助下創(chuàng)建,但我們?cè)趧?chuàng)建它時(shí)必須使用關(guān)鍵字“Temporary”。為了說(shuō)明臨時(shí)表的創(chuàng)建,我們使用以下示例 –
示例
mysql> CREATE TEMPORARY TABLE SalesSummary ( -> product_name VARCHAR(50) NOT NULL -> , total_sales DECIMAL(12,2) NOT NULL DEFAULT 0.00 -> , avg_unit_price DECIMAL(7,2) NOT NULL DEFAULT 0.00 -> , total_units_sold INT UNSIGNED NOT NULL DEFAULT 0 ); Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO SalesSummary -> (product_name, total_sales, avg_unit_price, total_units_sold) -> VALUES -> ('cucumber', 100.25, 90, 2); mysql> SELECT * FROM SalesSummary; +--------------+-------------+----------------+------------------+ | product_name | total_sales | avg_unit_price | total_units_sold | +--------------+-------------+----------------+------------------+ | cucumber | 100.25 | 90.00 | 2 | +--------------+-------------+----------------+------------------+ 1 row in set (0.00 sec)
登錄后復(fù)制
上述查詢(xún)已創(chuàng)建值并將其插入到名為“SalesSummary”的臨時(shí)表中。
以上就是什么是 MySQL 臨時(shí)表?我們?nèi)绾蝿?chuàng)建它們?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!