當然可以去PHPMYADMIN裡浏覽一下。但是終究有遺漏吧。所以自己寫了個,比較數據庫差異的腳本(PHP的),方便一下自己。當然代碼很簡單,就不講解了,貼代碼:
復制代碼 代碼如下:
<?
mysql_connect('localhost','root','root');
mysql_select_db('tablea'); //標准的數據庫
$q = mysql_query("show tables");
while($s = mysql_fetch_array($q)){
$name = $s[0];
$q1 = mysql_query("desc $name");
while ($s1 = mysql_fetch_array($q1)) {
$a[$name][] =$s1[0];
}
}
mysql_close();
mysql_connect('localhost','root','root');
mysql_select_db('tableb');//需要比較的數據庫
$q2 = mysql_query("show tables");
while($s2 = mysql_fetch_array($q2)){
$name2= $s2[0];
$q3 = mysql_query("desc $name2");
while ($s3 = mysql_fetch_array($q3)) {
$aa[$name2][] =$s3[0];
}
}
mysql_close();
$f = $e = array();
$str = $fuhao ='';
foreach($a as $k=>$v){
if(!is_array($aa[$k])){
$e[] = $k;
}
else{
if(count($aa[$k]) <> count($v)){
foreach($v as $k1=>$v1){
if(!in_array($v1,$aa[$k])){
$f[$k][] = $v1;
}
}
}
}
}
echo "<pre>";
print_r($e);//缺少表
print_r($f);//缺少表的字段
?>