How do I get the Parameter information of table?
I have table like

mysql> desc account;
Code:
+----------+--------------+------+-----+---------+-------+
| Field    | Type         | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| acct_num | int(11)      | NO   | PRI | NULL    |       |
| amount   | decimal(2,0) | YES  |     | NULL    |       |
+----------+--------------+------+-----+---------+-------+
I want all the information like colname, datatype, collength, precision, scale, Nullable. I tried using the
Code:
MYSQL_FIELD *fields;
unsigned int num_fields; 

pResult = mysql_store_result(MySQLDB);
num_fields= mysql_num_fields(pResult);
fields = mysql_fetch_fields(pResult);    
for( i = 0; i < num_fields; i++)
{
  printf("Field %u is %s\n", i, fields[i].name);
}
It is giving me output like :
Field
Type
NULL
KEY
Default

row = mysql_fetch_row(pResult);
it will give me output as :
acct_num

Which I wanted to get.

But other information not gettting like datatype, precision, scale, nullable.

If I fire a query select * from account;It will gives me What I want in fields.
But it is not good if the there are 100 table which has millions of records and I want information of each table.
Is ther any other way to get only the reuqired information?

Last edited by shabbir; 12Jun2009 at 15:44.. Reason: Code blocks