How to Show Schema of a Table in MySQL Database?

A table schema in MySQL database defines the structure of table, including columns, data types, relationships between columns, etc. It is a blueprint for the table, describing how data is organized in the table and how it relates to other tables in the database.

To see the schema of a table in MySQL database, use the DESCRIBE command.

How to Check Table Schema in MySQL Database

To check a table schema in MySQL, use the following command syntax:

DESCRIBE databasename.tableName;

Check the Schema of a table in MySQL Example

Let us look at an example, where we will check the schema of a table in MySQL.

First, let’s create a database and demo table.

Query:

CREATE DATABASE w3wikiDatabase;

USE w3wikiDatabase;

CREATE TABLE Beginner (
GeekID INTEGER PRIMARY KEY,
GeekName VARCHAR(255) NOT NULL,
GeekRank INTEGER NOT NULL,
GeekSchool VARCHAR(255) NOT NULL
);

Display the table structure (Schema) in MySQL

Here is the MySQL query to display the table schema

Query:

DESCRIBE w3wikiDatabase.Beginner;

Output:

Table Schema

Check the Table Schema in Other DBMS

Here we have provided the query syntax to check table schema in other DBMS.

Check the Table Schema in Oracle Database

To check table schema in an Oracle Database use the DESC keyword.

Query Syntax:

DESC tableName

Check the Table Schema in SQL Server Database

In SQL Server, we use Transact-SQL :

Query Syntax:

EXEC sp_help 'dbo.tableName';

Using the above query, we can get the whole description of the table, including its properties like column names, data types used for each column, and constraints.