mysql取得数据库所有表名和字段注释

1、取字段注释

Select COLUMN_NAME 列名, DATA_TYPE 字段类型, COLUMN_COMMENT 字段注释
from INFORMATION_SCHEMA.COLUMNS
Where table_name = 'companies'##表名
AND table_schema = 'testhuicard'##数据库名
AND column_name LIKE 'c_name'##字段名 

2、取得表注释

Select table_name 表名,TABLE_COMMENT 表注释 from INFORMATION_SCHEMA.TABLES Where table_schema = 'testhuicard' ##数据库名 
AND table_name LIKE 'companies'##表名 

mysql手册:23.1. INFORMATION_SCHEMA表
3、取得某数据库下所有表的注释

$tt = mysql_query(“show table status;”);
t a b l e i n f o = a r r a y ( ) ; w h i l e ( table_info=array(); while( tableinfoarray();while(re = mysql_fetch_array(KaTeX parse error: Expected '}', got 'EOF' at end of input: … //re[“Comment”],这个就是表的注释
$table_info[] = $re;
} …

你可能感兴趣的:(mysql)