Example of DESCRIBE TABLE
We have two tables named student, fees with some columns.
Let’s perform the DESCRIBE TABLE command in the student table and understand the output.
Query:
DESCRIBE students;
Output:
Explanation:
Lets understand the output of each column in the table, including its data type, nullability, constraints, and default values:
- student_id : This shown as type int. The NO shows it cannot be NULL. As a primary key (PRI). As Extra its have auto_increment for autogenerated integer.
- first_name : This is a varchar(50) column, it can be up to 50 characters in length. The NO shows it cannot be NULL.
- last_name : same as per the first_name column.
- date_of_birth : This column is of type of date. The NULL field is marked as YES, meaning it allows NULL values.
- email : A varchar(100) type column, it can be up to 100 characters in length. The NULL field is marked as YES, meaning it stores NULL values. The UNI key shows it has a unique constraint.
- Registration_date : This is a timestamp column. It can have NULL values. The CURRENT_TIMESTAMP and DEFAULT_GENERATED set automatically default value using the current timestamp when we add a new row.
- is_active : This column is of type tinyint(1), it allows NULL values, and the default value is 1.
Let’s perform the DESCRIBE TABLE command in the fees table and understand the output.
Query:
DESCRIBE fees
Output:
Explanation:
- fee_id : This column is type of int. The NULL value field is NO, so it can’t be empty. As a primary key (PRI). As Extra its have auto_increment for autogenerated integer.
- student_id : This column is of type int. It sores NULL values. MUL means it’s part of multiple indexes. This column has a foreign key referencing to the student_id in the student table.
- amount : This column is type of decimals. It can have up to 8 digits in total, 2 being after the dot. The NULL value field is NO, so it can’t be empty.
- payment_date : This column is type of date. It stores NULL values. MUL means it’s part of multiple indexes.
MySQL Describe Table
MySQL is an open–source relational database management system (RDBMS). It is one of the most popular databases globally, known for its reliability, and scalability. MySQL is designed to run on various operating systems, including Windows, Linux, macOS, and more. It is known for its high performance, quick data retrieval, and efficient data storage. It provides robust security features, including user authentication, access control, and data encryption.
In this article, we will understand how to use the DESCRIBE TABLE command using steps to follow, examples, and so on.
Contact Us