---
title: "mysql取得数据库所有表名和字段注释"
author: "daoshud1"
date: "2013-06-24T10:30:54Z"
tags: []
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2013-06-24T10:30:54Z"
id: 1893221
url: "https://daoshud1.iteye.com/blog/1893221"
---

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;");
       $table_info＝array();
       while($re = mysql_fetch_array($tt,MYSQL_ASSOC)){
                        //$re["Comment"],这个就是表的注释
                        $table_info[] = $re;
        } ......
 
```

 

更新自增值 ALTER TABLE \[Table]members AUTO\_INCREMENT=10000