|
<? $v_dbname = ""; //データベースの名前を変数へ代入 $v_user = ""; //ユーザー名を変数へ代入 $v_password = ""; //パスワードを変数へ代入 ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <title>テーブル一覧</title> </head> <body> <div align="center"> <table width="350" border="0" bgcolor="#009999"> <tr> <td height="12"> <div align="center"><b><font color="#FFFFFF">テーブル一覧</font></b></div> </td> </tr> </table> <br> <table width="470" border="0" cellspacing="2" cellpadding="2" align="center"> <tr bgcolor="#113333" height="20"> <td width="120"> <div align="center"><b><font color="#FFFFFF">テーブル名</font></b></div> </td> <td width="100"> <div align="center"><b><font color="#FFFFFF">tableowner</font></b></div> </td> <td width="60"> <div align="center"><b><font color="#FFFFFF">Indexes</font></b></div> </td> <td width="60"> <div align="center"><b><font color="#FFFFFF">Rules</font></b></div> </td> <td width="60"> <div align="center"><b><font color="#FFFFFF">Triggers</font></b></div> </td> <td width="70"> <div align="center"><b><font color="#FFFFFF">項目数</font></b></div> </td> </tr> <? // Connect to DB if (@pg_connect("dbname=$v_dbname user=$v_user password=$v_password") == false) { print("unable to connect to database."); exit; } pg_exec("SET CLIENT_ENCODING = 'SJIS'"); $sql = "select t.*,c.relnatts from pg_class c,pg_tables t where c.relpages=10 and c.relkind='r' and c.relname = t.tablename;"; @$result = pg_exec($sql); if ($result == false) { printf("failed to exec SQL:¥"$sql¥""); exit; } $rows = pg_numrows($result); $iro = "CCEEEE"; for ($i = 0; $i < $rows; $i++) { $tablename = pg_result($result, $i, "tablename"); $tableowner = pg_result($result, $i, "tableowner"); $hasindexes = pg_result($result, $i, "hasindexes"); $hasrules = pg_result($result, $i, "hasrules"); $hastriggers = pg_result($result, $i, "hastriggers"); $relnatts = pg_result($result, $i, "relnatts"); if ($iro == "AACCCC") { $iro = "CCEEEE"; } else { $iro = "AACCCC"; } print ("<tr bgcolor=¥"#$iro¥" height=¥"26¥">"); print ("¥n"); print ("<td>$tablename</td>"); print ("¥n"); print ("<td>$tableowner</td>"); print ("¥n"); print ("<td><div align=¥"center¥">".($hasindexes == "t" ? "有" : "")."</div></td>"); print ("¥n"); print ("<td><div align=¥"center¥">".($hasrules == "t" ? "有" : "")."</div></td>"); print ("¥n"); print ("<td><div align=¥"center¥">".($hastriggers == "t" ? "有" : "")."</div></td>"); print ("¥n"); print ("<td><div align=¥"right¥">$relnatts</div></td>"); print ("¥n"); print ("</tr>¥n"); } pg_close(); ?> </table> <hr> </div> </body> </html> |