Reputation: 6799
If two users create two TEMPORARY tables at the same time in my mysql database using a PHP script, will it create two different tables? Can those users use their own table without facing any trouble and will those table be automatically deleted?
thanks :)
CREATE TEMPORARY TABLE TempTable ( ID int, Name char(100) ) TYPE=HEAP;
INSERT INTO TempTable VALUES( 1, "Foo bar" );
SELECT * FROM TempTable;
DROP TABLE TempTable;
Upvotes: 1
Views: 1351
Reputation: 126015
As stated in the manual:
A
TEMPORARY
table is visible only to the current connection, and is dropped automatically when the connection is closed. This means that two different connections can use the same temporary table name without conflicting with each other or with an existing non-TEMPORARY
table of the same name. (The existing table is hidden until the temporary table is dropped.)
Upvotes: 3
Reputation: 122032
Temporary tables are created in a current session; so, two users can create two temp. tables at the same time in their threads. These tables will be removed on session closing.
Upvotes: 2