Retrieving Table Schemas in MySQL
The command for displaying the schema of a table in a MySQL database depends on the desired output format.
Formatted Output:
To generate a formatted display of the schema, use the following command:
describe [db_name.]table_name;
This command provides information on the table's columns, including their names, data types, constraints, and default values.
SQL Statement for Table Creation:
If you want to obtain an SQL statement that can be used to create the table with its current schema, use this command:
show create table [db_name.]table_name;
This command returns the SQL statement that was originally used to create the table, including all of its columns, indexes, and constraints.
The above is the detailed content of How to Retrieve Table Schemas in MySQL?. For more information, please follow other related articles on the PHP Chinese website!