Creating Temporary Tables (SQL)

Kasim Ali
2 min readNov 7, 2022

--

In my last post, we went over how to create tables using SQL. Another option we have is to use temporary tables.

We will learn how to:

  • Create temporary tables.
  • Describe the limitations of temporary tables.
  • How to effectively find the syntax for database management systems.

Temporary tables are deleted after the current session is terminated. The advantages of this are that it is a lot faster than making a real table. Could be a great advantage when you are using complicated queries.

Here is how we create a temporary table.

CREATE TEMPORARY TABLE Burgers As
(
SELECT *
FROM foods
WHERE food_type = 'burgers'
)

In this table, we are making a temporary table called burgers that selects all the results from the foods table where the food_type is equal to ‘burgers’.

Potential issues.

You will run into differences in syntax, what might be useful is to use stack overflow or google to find the differences. You could use keywords such as ‘Statement’ or ‘RDBMS’.

This will give you the answers you need, think about how many others would have needed the information you currently need.

I would also love to connect on Twitter, LinkedIn or on my Website. I am not sure what value I could provide you with but if you reach out, I would be more than happy to have a conversation or talk about what I have written here.

--

--

Responses (2)