Get the App
SLTechnology News&Howtos  ›  Database  › 

A simple way for MySQL to use temporary tables

Shulou Source: shulou.com Published: 2022-06-01 19:14:04 09月29日 Update

This article mainly tells you about the simple method of using temporary tables in MySQL. You can check the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here, so let's go straight to the topic. I hope this article on the simple method of using temporary tables in MySQL can bring you some practical help.

Temporary tables have an effect only when connecting to the database. Once resources are released, they are deleted. When the connection is closed, Mysql automatically deletes the table and frees up all space. Use a simple instance of the MySQL temporary table to create commands CREATE TEMPORARY CREATE TEMPORARY TABLE SalesSummary (- > product_name VARCHAR (50) NOT NULL- >, total_sales DECIMAL (12Magne2) NOT NULL DEFAULT 0.00- >, avg_unit_price DECIMAL (7mem2) NOT NULL DEFAULT 0.00- >, total_units_sold INT UNSIGNED NOT NULL DEFAULT 0) Insert statement INSERT INTO SalesSummary- > (product_name, total_sales, avg_unit_price, total_units_sold)-> VALUES- > ('cucumber', 100.25, 90, 2)

Note that when you use the SHOW TABLES command to display a list of datasheets, you will not be able to see the SalesSummary table. If you exit the current MySQL session and use the SELECT command to read the previously created temporary table data, you will find that the temporary table does not exist in the database because the temporary table was destroyed when you quit.

MySQL uses the temporary table simple method to tell you here, for other related issues you want to know can continue to follow our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

Tags: Data methods commands specialties databases industries expertise topics books content examples reality effects datasheets news time terminology sections knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Xiaomi Linux OPPO Reno Shulou Technology