;", 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."/> ;", 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.">

Home  >  Article  >  Backend Development  >  php code to delete database

php code to delete database

藏色散人
藏色散人Original
2020-08-20 10:01:563190browse

The code for php to delete a database is "drop database e5c249aa15ff4c64720f99bfaecf8a60;", 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 <数据库名>;

For example, to delete a database named RUNOOB:

mysql> drop database RUNOOB;

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:******

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

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);

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(默认)

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!

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