php批量更改數(shù)據(jù)庫表前綴實(shí)現(xiàn)方法
通過下面這個(gè)方法,輕松搞定,代碼如下,有用到的頂起。
<?php
$database = "databaseName"; //數(shù)據(jù)庫名稱
$user = "root"; //數(shù)據(jù)庫用戶名
$pwd = "pwd"; //數(shù)據(jù)庫密碼
$replace ='pre_'; //替換后的前綴
$seach = 'pre1_'; //要替換的前綴
$db=mysql_connect("localhost","$user","$pwd") or die("連接數(shù)據(jù)庫失?。?.mysql_error()); //連接數(shù)據(jù)庫
$tables = mysql_list_tables("$database");
while($name = mysql_fetch_array($tables)) {
$table = str_replace($seach,$replace,$name['0']);
mysql_query("rename table $name[0] to $table");
}
?>
如果是添加前綴只需要變化一點(diǎn)點(diǎn)
$table = str_replace($seach,$replace,$name['0']);換成
$table = $replace.$name['0'];
就可以了。
相關(guān)文章
thinkPHP5.0框架引入Traits功能實(shí)例分析
這篇文章主要介紹了thinkPHP5.0框架引入Traits功能,結(jié)合實(shí)例形式分析了Traits的概念、功能及thinkPHP5.0中Traits功能的使用方法,需要的朋友可以參考下2017-03-03
Laravel 簡單實(shí)現(xiàn)Ajax滾動(dòng)加載示例
今天小編就為大家分享一篇Laravel 簡單實(shí)現(xiàn)Ajax滾動(dòng)加載示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-10-10
PHPMYADMIN導(dǎo)入數(shù)據(jù)最大為2M的解決方法
PHPMYADMIN還原數(shù)據(jù)庫的時(shí)候上傳的最大限制:2,048 KB,數(shù)據(jù)庫稍微大一些就無法處理,要么使用其他的備份還原工具如帝國備份王,要么就分卷導(dǎo)出,那么有沒有辦法還使用PHPMYADMIN來處理呢2012-04-04

