How to list temporary table columns in MySQL?

MySQLMySQLi Database

To list temporary table columns in MySQL, let us first create a temporary table.

Here’s an example. We have created a temporary table with some columns that includes the details of a student −

mysql> CREATE TEMPORARY TABLE DemoTable745 (
   StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   StudentName varchar(100),
   StudentAge int,
   StudentAddress varchar(100),
   StudentCountryName varchar(20)
);
Query OK, 0 rows affected (0.00 sec)

Following is the query to list temporary table columns in MySQL−

mysql> show columns from DemoTable745;

This will produce the following output -

+--------------------+--------------+------+-----+---------+----------------+
| Field              | Type         | Null | Key | Default | Extra          |
+--------------------+--------------+------+-----+---------+----------------+
| StudentId          | int(11)      | NO   | PRI | NULL    | auto_increment |
| StudentName        | varchar(100) | YES  |     | NULL    | NULL           |
| StudentAge         | int(11)      | YES  |     | NULL    | NULL           |
| StudentAddress     | varchar(100) | YES  |     | NULL    | NULL           |
| StudentCountryName | varchar(20)  | YES  |     | NULL    | NULL           |
+--------------------+--------------+------+-----+---------+----------------+
5 rows in set (0.05 sec)
raja
Published on 22-Aug-2019 11:42:05
Advertisements