It is sometimes useful to create tables for temporary use. This can be done by using the CREATE TEMPORARY TABLE command rather than CREATE TABLE. A temporary table differs from a non- temporary table in the following ways:
• It's visible only to the client (and connection) that created it and may be used only by that client
(and connection). This means that different clients (even with different connections) can create
temporary tables that have the same name and no conflict occurs.
• A temporary table exists only for the duration of the connection in which it was created. The
server drops a temporary table automatically when the client connection ends if the client has not
already dropped it.
• A temporary table may have the same name as a non-temporary table. The non-temporary table becomes hidden to the client that created the temporary table as long as the temporary table exists.
• A temporary table can be renamed only with ALTER TABLE. The RENAME TABLE command
can not be used. In this example a temporary table is created from the existing City table, which contains the names of all the cities in Texas (US);
CREATE TEMPORARY TABLE texas SELECT Name FROM City WHERE
District='Texas';
Comments
Post a Comment