How to create and drop temporary table in MySQL
Temporary table are special type of tables which are present only for the session in which they are created. Once the session is closed , the temporary tables dropped automatically.
As developers we often create the temporary tables to store the results so we can use in different parts of programs. Sometime you create them so you can perform different calculations and finally save the results in some permanent table.
Below are few of the things you need to remember working with Temporary tables in MySQL.
- To create Temporary table, you will say "create Temporary table TableName".
- To drop the temporary table, you can use drop temporary table TableName. If you don't drop the temporary table but end the session, the table is dropped anyways.
- Different users or in different sessions you can have the temporary tables with same name.
- The temporary table can be created with the same name the permanent table exists. In case you have created the temporary table with the same permanent table name, anything you will do, you will be using the temporary table.
- I will not suggest to use the same name like permanent table, that can cause confusion.
- If you will drop the table , in case temporary and permanent table have the same name, it will drop the temporary table.
Let's say if we would like to create temporary table with name mytable in MySQL. you can use below syntax.
create temporary table mytable(id int, name varchar(100));
To drop temporary table, you can use "drop temporary table TableName".
Thank you so much for providing information about SSIS and other related components of MySQL and supplementing database operations.
ReplyDeleteSSIS Postgresql Read
Đặt vé máy bay tại Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ hạng thương gia
vé máy bay hải phòng sài gòn giá rẻ
vé máy bay nha trang - hà nội
dat ve may bay ha noi nha trang
vé máy bay đi đà lạt giá rẻ
đặt xe taxi sân bay