Reputation: 2259
How select column names ,column data type, key column of a table in mysql by passing the table name. I am using mysql 5.5
Upvotes: 1
Views: 1939
Reputation: 6667
desc
or SHOW FIELDS FROM
.Code:
`use testDB;`
``desc `testDB`.`images`;``
-- or
`SHOW FIELDS FROM images;`
See my previous answer How to show mysql table columns data type?, it solves your problem.
The results are shown in attached image file.
Upvotes: 0
Reputation: 1315
Try this:
Get structure of table
DESCRIBE table;
SELECT * FROM information_schema.tables where table_name = 'table';
Get a list of the tables in your database.
SHOW TABLES;
Whole database structure
mysqldump database_name
Upvotes: 0
Reputation: 204756
Pick the info you need from
SELECT *
FROM information_schema.columns
or
SELECT *
FROM information_schema.tables
Upvotes: 4