您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php生成mysql数据字典

2025/10/1 4:08:32发布12次查看
有时候我们拿到别人的数据库,却没有数据字典,这个php小程序帮你轻松解决。
代码是网上找到的,当然,这段代码也仅仅是生成了数据字典,视图,存储过程等等是木有的哦。
$v) { $sql = select * from ; $sql .= information_schema.tables ; $sql .= where ; $sql .= table_name = {$v[table_name]} and table_schema = {$database}; $table_result = mysql_query($sql, $mysql_conn); while ($t = mysql_fetch_array($table_result) ) { $tables[$k][table_comment] = $t[table_comment]; } $sql = select * from ; $sql .= information_schema.columns ; $sql .= where ; $sql .= table_name = {$v[table_name]} and table_schema = {$database}; $fields = array(); $field_result = mysql_query($sql, $mysql_conn); while ($t = mysql_fetch_array($field_result) ) { $fields[] = $t; } $tables[$k][column] = $fields;}mysql_close($mysql_conn);$html = ;//循环所有表foreach ($tables as $k=>$v) { //$html .= . $v[table_comment] . ; $html .= ; $html .= . $v[table_name] . . $v[table_comment]. ; $html .= 字段名数据类型默认值 允许非空 自动递增备注
; $html .= ; foreach ($v[column] as $f) { $html .= . $f[column_name] . ; $html .= . $f[column_type] . ; $html .= . $f[column_default] . ; $html .= . $f[is_nullable] . ; $html .= . ($f[extra]==auto_increment?是: ) . ; $html .= . $f[column_comment] . ; $html .=
; } $html .=
;}//输出echo .$title.;echo .$title.;echo $html;echo ;?>
运行后的结果:
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product