Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table doesn't exist After Creating a Temp Table

Hi I am creating a temp table and insert a record using

CREATE TEMPORARY TABLE temp_table_extension_details (
                  `Id` int NOT NULL,
                  `model_code` varchar(10),
                  `model_description` varchar(50),
                  `eta` varchar(100),
                  `options` varchar(100),
                  `order_numbers` varchar(200),
                  PRIMARY KEY(Id)
                );


 INSERT INTO temp_table_extension_details (model_code,model_description,eta,options,order_numbers) 
    VALUES('ABCD','description','eta','abc,bcd,def','123,234,345,456');

I tried this using PHPMyadmin and it says # 1 row affected.

but when i try to select the data using

SELECT * FROM temp_table_extension_details 

It gives me an error and says

SELECT * FROM temp_table_extension_details 
 LIMIT 0, 25 
MySQL said: Documentation

#1146 - Table 'trans.temp_table_extension_details' doesn't exist .

Is there any reson for this , i want to create a temp table and insert some data , later i will select all the data from it and delete the temp table .

Thanks in advance .

like image 766
Kanishka Panamaldeniya Avatar asked Jul 16 '15 02:07

Kanishka Panamaldeniya


People also ask

How long does temporary table exist?

Temporary tables can have a Time Travel retention period of 1 day; however, a temporary table is purged once the session (in which the table was created) ends so the actual retention period is for 24 hours or the remainder of the session, whichever is shorter.

How do I display a temporary table in SQL?

The name of a temporary table must start with a hash (#). Now, to see where this table exists; go to “Object Explorer -> Databases -> System Databases-> tempdb -> Temporary Tables”. You will see your temporary table name along with the identifier.

How do I know if a table is a global temporary table?

We can also use the following query to display all Oracle global temporary tables: select table_name from all_tables where temporary = 'Y';


1 Answers

Temporary tables only exist during the connection. If you create it with one query and then do a separate query on a new connection it is already gone.

like image 151
Chris Muench Avatar answered Sep 23 '22 06:09

Chris Muench