DATABASE Create display and delete

Database is a collection of structured information or data.

Creating a database
CREATE DATABASE my_database;
If the database is already there then MySQL will return error. We can check first before creating the database.
CREATE database IF NOT EXISTS  my_database;
The user account must have privileges to create database. Contact your database admin to get required privilege if you are getting ERROR 1044 (42000): Access denied for user message.

To know which database is currently in use
SELECT DATABASE()

Listing all Databases

SHOW DATABASES in Phpmyadmin
SHOW databases;
We can use LIKE to filter the listing of database
SHOW databases LIKE '%plus2%';
This will list all databases having plus2 any where in the database name.

More on SHOW Database and table

Opening a Database

Creating a database does not mean it is selected for use. We have to explicitly call it before using.
USE my_database;
With this our my_database is available to us.

Deleting Database

DROP DATABASE my_database;
If the database is not available then this will generate error, so we can check before deleting.
DROP DATABASE IF EXISTS my_database;

PHP Script to List all Databases
SQL Show all tables in Database How to delete table or database
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer