Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show the schema of a table in a MySQL database?

From the MySQL console, what command displays the schema of any given table?

like image 246
dlamblin Avatar asked Sep 30 '09 15:09

dlamblin


People also ask

How do you find the schema of a table?

For a list of tables in the current schema, use the Show Tables command. For a list of views in the current schema, use the Show Views command. For a list of available schemas, use the Show Schemas command. If the table or view is in a particular schema, qualify it with the schema name.

How do I view a database schema?

You can get a list of the schemas using an SSMS or T-SQL query. To do this in SSMS, you would connect to the SQL instance, expand the SQL database and view the schemas under the security folder. Alternatively, you could use the sys. schemas to get a list of database schemas and their respective owners.

Which MySQL command shows the structure of a table?

After logging into the MySQL command line client and selecting a database, you can list all the tables in the selected database with the following command: mysql> show tables; (mysql> is the command prompt, and "show tables;" is the actual query in the above example).


2 Answers

For formatted output:

describe [db_name.]table_name; 

For an SQL statement that can be used to create a table:

show create table [db_name.]table_name; 
like image 75
Omry Yadan Avatar answered Oct 07 '22 01:10

Omry Yadan


SHOW CREATE TABLE yourTable; 

or

SHOW COLUMNS FROM yourTable; 
like image 44
Bobby Avatar answered Oct 07 '22 00:10

Bobby