
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How do I show the schema of a table in a MySQL database?
To show the schema, we can use the DESC command. This gives the description about the table structure.
The following is the syntax.
DESCRIBE yourDatabasename.yourTableName;
Let us implement the above syntax.
mysql> DESCRIBE business.student;
The following is the output.
+-------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | id | int(11) | YES | MUL | NULL | | | Name | varchar(100) | YES | MUL | NULL | | +-------+--------------+------+-----+---------+-------+ 2 rows in set (0.05 sec)
Syntax to show the schema of a table with the help of show create table command.
show create table yourDatabasename.yourTableName;
The following is the query.
mysql> show create table business.student;
Here is the output displaying the schema.
+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | student | CREATE TABLE `student` (`id` int(11) DEFAULT NULL, `Name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, KEY `NameStuIndex` (`Name`), KEY `idIndex` (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = | +---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.03 sec)
- Related Articles
- How do I show unique constraints of a table in MySQL?
- How do I remove a MySQL database?
- How do I see what character set a MySQL database / table / column is?
- Checking a table inside a schema in SAP HANA database
- How do I clone the structure of a table in MySQL?
- Refreshing a schema after creating a table in SAP HANA database
- How to alter the database engine of a MySQL database table?
- How do I get the creation date of a MySQL table?
- How do I list all the columns in a MySQL table?
- How do I detect if a table exist in MySQL?
- How do I alter a MySQL table column defaults?
- How do I show a MySQL warning that just happened?
- Difference between Schema and Database in MySQL?
- How do I view the auto_increment value for a table in MySQL?
- How do I add a check constraint to a table in MySQL?

Advertisements