- 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
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)
Advertisements