PHP匯出資料庫資料字典指令碼

2022-03-18 19:43:43 字數 1878 閱讀 5061

<?php/**

* @author change */

//配置資料庫

$dbserver = "192.168.1.218:3306";

$dbusername = "admin";

$dbpassword = "111";

$database = 'test';

//其他配置

$title = '資料字典';

$mysql_conn = @mysql_connect($dbserver, $dbusername, $dbpassword) or die("mysql connect is error.");

mysql_select_db($database, $mysql_conn

);mysql_query('set names utf8', $mysql_conn

);$table_result = mysql_query('show tables', $mysql_conn

);//

取得所有的表名

while ($row = @mysql_fetch_array($table_result

)) //

迴圈取得所有表的備註

foreach ($tables

as$k => $v

) ' and table_schema = ''";

$table_result = mysql_query($sql, $mysql_conn

);

while ($t = mysql_fetch_array($table_result

))

$sql = 'select * from ';

$sql .= 'information_schema.columns ';

$sql .= 'where ';

$sql .= "table_name = '' and table_schema = ''";

$fields = array

();

$field_result = mysql_query($sql, $mysql_conn

);

while ($t = @mysql_fetch_array($field_result

))

$tables[$k]['column'] = $fields;}

mysql_close($mysql_conn

);?>

class="box"><?php if (!empty($tables)): ?>

<?php foreach ($tables

as$k => $v): ?>class="table table-hover table-bordered" width="80%">

<?=$v['table_name'];?>

class="success">

欄位名資料型別

預設值允許非空

自動遞增

注釋

<?php foreach ($v['column'] as

$f): ?>

<?=$f['column_name'];?>

<?=$f['column_type'];?>

<?=$f['column_default'];?>

<?=$f['is_nullable'];?>

<?=$f['extra'] == 'auto_increment' ? "√" : "";?>

<?=$f['column_comment'];?>

<?php endforeach?>

<?php endforeach?>

<?php endif?>

sql server 資料庫 資料字典指令碼

use yourdatabase 指定要生成資料字典的資料庫 goselect 表名 case when a.colorder 1 then d.name else end,表說明 case when a.colorder 1 then isnull f.value,else end,字段序號 a....

mysql資料庫匯出表的資料字典

select column name,column type,is nullable,column comment from information schema.columns where table schema yck bts db and table name da menu 第乙個條件是資...

資料字典 資料庫概念

來自 資料字典是oracle資料庫中最重要的部分之一,資料字典是一系列唯讀的表,用來提供資料庫的資訊。資料字典包括 所有方案物件的定義,如 表 檢視 索引 聚簇 同義詞 序列 過程 函式 包 觸發器等 分配給方案物件的空間,以及當前使用情況 列的預設值 完整性約束資訊 oracle使用者的名稱 使用...