Site icon TestingDocs.com

MySQL SHOW CREATE TABLE Statement

Overview

In this tutorial, we will learn about SHOW CREATE TABLE Statement. The SHOW CREATE TABLE statement produces a statement that can create a table with the same columns, options as the current table. This can be helpful in understanding the structure of table.

It can also be used as a basis for the syntax to create a new table.

Syntax

The general syntax of the statement is as follows:

mysql> SHOW CREATE TABLE <table_name>

Example

For example, to display the CREATE TABLE statement used to create the Country table in the world MySQL database, we can use the following statement:

mysql> SHOW CREATE TABLE Country \G

*************************** 1. row ***************************
Table: Country
Create Table: CREATE TABLE `country` (
`Code` char(3) NOT NULL DEFAULT ”,
`Name` char(52) NOT NULL DEFAULT ”,
`Continent` enum(‘Asia’,’Europe’,’North America’,’Africa’,’Oceania’,’Antarctica’,’South America’)
NOT NULL DEFAULT ‘Asia’,
`Region` char(26) NOT NULL DEFAULT ”,
`SurfaceArea` float(10,2) NOT NULL DEFAULT ‘0.00’,
`IndepYear` smallint DEFAULT NULL,
`Population` int NOT NULL DEFAULT ‘0’,
`LifeExpectancy` float(3,1) DEFAULT NULL,
`GNP` float(10,2) DEFAULT NULL,
`GNPOld` float(10,2) DEFAULT NULL,
`LocalName` char(45) NOT NULL DEFAULT ”,
`GovernmentForm` char(45) NOT NULL DEFAULT ”,
`HeadOfState` char(60) DEFAULT NULL,
`Capital` int DEFAULT NULL,
`Code2` char(2) NOT NULL DEFAULT ”,
PRIMARY KEY (`Code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.08 sec)

 

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Exit mobile version