- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MySQL query to display structure of a table
To display structure of a table, following is the syntax −
show create table yourTableName;
Let us first create a table −
mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeFirstName varchar(100), -> EmployeeLastName varchar(100), -> EmployeeAge int, -> isMarried tinyint(1), -> EmployeeAddress varchar(100), -> EmployeeCountryName varchar(100) -> ); Query OK, 0 rows affected (0.62 sec)
Here is the query to display structure −
mysql> show create table DemoTable;
Output
This will produce the following output −
+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | DemoTable | CREATE TABLE `DemoTable` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `EmployeeFirstName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `EmployeeLastName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `EmployeeAge` int(11) DEFAULT NULL, `isMarried` tinyint(1) DEFAULT NULL, `EmployeeAddress` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `EmployeeCountryName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
Advertisements