Home >Backend Development >PHP Problem >How to change the php table name

How to change the php table name

angryTom
angryTomOriginal
2019-10-31 14:36:543108browse

How to change the php table name

How to change the php table name

Here we use mysqli process-oriented method to connect to the database and execute the change table name operation.

Use ALTER TABLE `a` RENAME TO `b`; statement to modify the table name.

<?php
$serve = &#39;localhost:3306&#39;;
$username = &#39;root&#39;;
$password = &#39;admin123&#39;;
$dbname = &#39;examples&#39;;
$link = mysqli_connect($serve,$username,$password,$dbname);
mysqli_set_charset($link,&#39;UTF-8&#39;); // 设置数据库字符集
$result = mysqli_query($link,&#39;ALTER TABLE `a` RENAME TO `b`&#39;);
if($result){
    echo &#39;更名成功&#39;;
}else{
    echo &#39;更名失败&#39;;
}
 ?>

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to change the php table name. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more