java baba
java baba

Reputation: 2259

How select column names ,column data type, key column of a table in mysql

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

Answers (3)

UdayKiran Pulipati
UdayKiran Pulipati

Reputation: 6667

  1. Select database,
  2. execute command using 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

Shamse Alam
Shamse Alam

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

juergen d
juergen d

Reputation: 204756

Pick the info you need from

SELECT * 
FROM information_schema.columns

or

SELECT * 
FROM information_schema.tables

Upvotes: 4

Related Questions