SQL - SPLessons

SQL Temporary Tables

Home > Lesson > Chapter 53
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQL Temporary Tables

SQL Temporary Tables

shape Description

The SQL RDBMS is a database management system that can perform the accompanying operations.
  • Enables one to create a database with tables, sections and lists.
  • Assures the Referential Integrity among the rows of different tables in the current database.
  • Consequently updates the indexes .
  • Reads an SQL query and joins data from different database tables.
SQL Temporary Tables are supported by RDBMS. The SQL Temporary tables are the incredible components that store and process the intermediate results by utilizing the update, joins and selection operations that are commonly used in SQL Server tables. SQL Temporary Tables are exceptionally helpful now and again to store temporary data. As the name temporary tables suggests, the SQL Temporary Tables are temporary and will be erased when the current customer session ends.

shape Examples

The below example describes the usage of temporary files. [c] sql> CREATE TEMPORARY TABLE Employee ( product_name VARCHAR(50) NOT NULL,total_sales DECIMAL(12,2) NOT NULL,avg_unit_price DECIMAL(7,2) NOT NULL,total_units_sold INT UNSIGNED NOT NULL ); Query OK, 0 rows affected (0.00 sec) sql> INSERT INTO Employee(product_name, total_sales, avg_unit_price, total_units_sold)VALUES('cucumber', 100.25, 90, 2); sql> SELECT * FROM Employee; +------------------+---------------+-----------------+-------------------+ | product_name | total_sales   | avg_unit_price  | total_units_sold  | +------------------+---------------+-----------------+-------------------+ |cucumber | 100.25 | 90.00 | 2 | +------------------+---------------+-----------------+-------------------+ 1 row in set (0.00 sec) [/c] Here all the calculations were performed accordingly and list all the temporary table values.

Summary

shape Key Points

    • SQL Temporary Tables - These are the incredible components in SQL database that are primarily used to store and process intermediate results by using the selection, update, and join capabilities that are used with the typical SQL Server tables.