php code to delete database

藏色散人
Release: 2023-03-04 20:06:01
Original
3112 people have browsed it

The code for php to delete a database is "drop database ;", where the drop command is used to delete the database, and the value of the parameter "database" specifies the name of the database to be deleted.

php code to delete database

Recommended: "PHP Video Tutorial"

MySQL Delete Database

Use an ordinary user to log in to the MySQL server. You may need specific permissions to create or delete a MySQL database, so we use the root user to log in. The root user has the highest permissions.

Be very careful when deleting the database, because all data will disappear after executing the delete command.

drop command deletes the database

drop command format:

drop database <数据库名>;
Copy after login

For example, to delete a database named RUNOOB:

mysql> drop database RUNOOB;
Copy after login

Use mysqladmin to delete the database

You can also use the mysql mysqladmin command to execute the delete command in the terminal.

The following example deletes the database RUNOOB (the database has been created in the previous chapter):

[root@host]# mysqladmin -u root -p drop RUNOOB
Enter password:******
Copy after login

After executing the above delete database command, a prompt box will appear to confirm whether the database is really deleted. :

Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.
Do you really want to drop the &#39;RUNOOB&#39; database [y/N] y
Database "RUNOOB" dropped
Copy after login

Use PHP script to delete database

PHP uses the mysqli_query function to create or delete a MySQL database.

This function has two parameters and returns TRUE when executed successfully, otherwise it returns FALSE.

Syntax

mysqli_query(connection,query,resultmode);
Copy after login

Parameters

connection required. Specifies the MySQL connection to use.

query Required, specifies the query string.

resultmode

Optional. a constant. Can be any of the following values:

MYSQLI_USE_RESULT(如果需要检索大量数据,请使用这个)
MYSQLI_STORE_RESULT(默认)
Copy after login

The above is the detailed content of php code to delete database. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!