Continuing my series on how same things can be done differently in SQL Server and MySQL, in this post, we will see temporary table support in SQL Server vs MySQL.
We may often need to create a temporary table while processing data to provide a workspace for storing intermediate results. Both SQL Server and MySQL support temporary tables.
In SQL Server, all temporary tables should be prefixed by the # sign
create table #test
insert into #test(id, names)
select * from #test
We can drop this table by using a DROP command
DROP table #test
In MySQL, we have to use the keyword 'temporary' when creating a temporary table
Consider the following code
create temporary table if not exists test
insert into test(id, names)
select * from test
The above creates a temporary table called test in the current session if it is not already available. To drop a temporary table in MySQL, we can use the following code
Did you like this post?
|subscribe via rss||subscribe via e-mail|
|print this post||follow me on twitter|