- MariaDB - Useful Functions
- MariaDB - Backup Loading Methods
- MariaDB - Backup Methods
- MariaDB - SQL Injection Protection
- MariaDB - Managing Duplicates
- MariaDB - Sequences
- MariaDB - Table Cloning
- MariaDB - Temporary Tables
- Indexes & Statistics Tables
- MariaDB - Alter Command
- MariaDB - Transactions
- MariaDB - Regular Expression
- MariaDB - Null Values
- MariaDB - Join
- MariaDB - Order By Clause
- MariaDB - Like Clause
- MariaDB - Delete Query
- MariaDB - Update Query
- MariaDB - Where Clause
- MariaDB - Select Query
- MariaDB - Insert Query
- MariaDB - Drop Tables
- MariaDB - Create Tables
- MariaDB - Data Types
- MariaDB - Select Database
- MariaDB - Drop Database
- MariaDB - Create Database
- MariaDB - Connection
- MariaDB - PHP Syntax
- MariaDB - Administration
- MariaDB - Installation
- MariaDB - Introduction
- MariaDB - Home
MariaDB Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
MariaDB - Temporary Tables
Some operations can benefit from temporary tables due to speed or disposable data. The pfe of a temporary table ends at the termination of a session whether you employ them from the command prompt, with a PHP script, or through a cpent program. It also does not appear in the system in a typical fashion. The SHOW TABLES command will not reveal a pst containing temporary tables.
Create a Temporary Table
The TEMPORARY keyword within a CREATE TABLE statement spawns a temporary table. Review an example given below −
mysql>CREATE TEMPORARY TABLE order ( item_name VARCHAR(50) NOT NULL , price DECIMAL(7,2) NOT NULL DEFAULT 0.00 , quantity INT UNSIGNED NOT NULL DEFAULT 0 );
In creating a temporary table, you can clone existing tables, meaning all their general characteristics, with the LIKE clause. The CREATE TABLE statement used to spawn the temporary table will not commit transactions as a result of the TEMPORARY keyword.
Though temporary tables stand apart from non-temporary and drop at the end of a session, they may have certain confpcts −
They sometimes confpct with ghost temporary tables from expired sessions.
They sometimes confpct with shadow names of non-temporary tables.
Note − Temporary tables are permitted to have the same name as an existing non-temporary table because MariaDB views it as a difference reference.
Administration
MariaDB requires granting privileges to users for creating temporary tables. Utipze a GRANT statement to give this privilege to non-admin users.
GRANT CREATE TEMPORARY TABLES ON orders TO machine122 @ localhost ;
Drop a Temporary Table
Though temporary tables are essentially removed at the end of sessions, you have the option to delete them. Dropping a temporary table requires the use of the TEMPORARY keyword, and best practices suggest dropping temporary tables before any non-temporary.
mysql> DROP TABLE order;Advertisements