Are the changes made to a temporary table reflected in their original tables?

1

I create a temporary table and insert data from other tables. If these data are modified, are these modifications reflected in their original tables?

Here my temporary table:

DROP TEMPORARY TABLE IF EXISTS categoriasaseleccionar; CREATE TEMPORARY TABLE categoriasaseleccionar (nombre TEXT) ;  INSERT INTO categoriasaseleccionar (nombre) VALUES ('Todas'); INSERT INTO categoriasaseleccionar (nombre) SELECT nombre FROM categoriadeproductos; 

and I make an update for example

UPDATE categoriasaseleccionar SET nombre = 'caramelos' WHERE nombre = 'caramelitos';

Assuming that the names are never repeated, which is the rule that I have when entering a new record, also has KEY with its identifier, I avoid writing the parameters of the tables, which is definitely not necessary in this question.

The change made to the one named, "caramelitos" for "candies", is reflected in the table "categoryofproducts"

The question is simple, but fundamental for what I am doing! I hope you answer thank you very much!

By the way, can something be done to make the changes reflect if they can not?

    
asked by Bernardo Harreguy 05.09.2017 в 21:02
source

1 answer

2

Temporary table

Temporary tables are completely independent of the normal structure of your database, have no relationship and serve as a repository of data simply.

Which means that the changes made in these will not affect the values of the tables on which they have been fed.

You can make an UPDATE to a formal table of your database with the information found in the temporary table, for example:

Update MyTable2 m
SET m.field1 = ##MyTempTable.field1
FROM ##MyTempTable
WHERE m.field2 = ##MyTempTable.field2 
    
answered by 05.09.2017 / 22:21
source