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

How to change the php table name

angryTom
Release: 2023-02-28 08:28:01
Original
3100 people have browsed it

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;;
}
 ?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template