Snowflake Vs MS-SQL - Part 3

   



Temporary Tables 

 

MS-SQL Server 

When you create temporary table, you can NOT create with same name as that of main table. In SQL, you have to use # or ## to create temporary table.




However Snowflake does allow to create temporary table with same name as that of main table.

Consider you have a table "Main_Table" under DEV schema say with 1000 records and if you create temporary table without records then temporary table gets created.




When you fire a select query as below, it returns zero records. This means it pulls the records from newly created temporary table and not from the main table.



If you create a view on this newly created temp table and fire select statement on the view then you  get zero records.



If you move to different session/worksheet and fire select statement on view then you get actual count of the table. Because temporary table's scope is for a particular session.


And finally, when you drop this table, temporary table gets deleted, while actual Main_Table still exists.



 Yogesh Shinde

LinkedInProfile

<<< Back Next >>>

Comments

Popular posts from this blog

Snowflake Vs MS-SQL - Part 36 - SPLIT_TO_TABLE

Snowflake Vs MS-SQL - Part 63 - ON Clause & Cross Join

Snowflake Vs MS-SQL - Part 33 - INITCAP