explain what is a temporary table for 10 marks. also give it purpose of the temporary table..Identify the types of temporary table?

1 answer

A temporary table is a type of table that is created by a database system on a per-session basis. It exists only for the duration of a database session or until it is explicitly dropped. Temporary tables are typically used to store temporary data that is not needed beyond the current session.

The purpose of a temporary table is to provide a temporary storage solution for data that needs to be accessed repeatedly or manipulated in some way, without storing it permanently in the database. Temporary tables can be used to store intermediate results of complex queries, to hold data that needs to be processed multiple times, or to store data that is being transferred between different parts of a database system.

There are two types of temporary tables:

1. Local temporary tables: These tables are visible only to the current session and are automatically dropped once the session ends. They are created using the "#" prefix before the table name.

2. Global temporary tables: These tables are visible to all sessions and are dropped once all sessions that have referenced the table have closed. They are created using the "##" prefix before the table name.

In summary, temporary tables provide a temporary storage solution for data that needs to be manipulated or accessed repeatedly within a database session. They can be local or global, depending on the scope of the session or sessions in which they are used.