DATABASE Create display and delete
Database is a collection of structured information or data.
Creating a database
If the database is already there then MySQL will return error. We can check first before creating the database.
CREATE DATABASE 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.
CREATE database IF NOT EXISTS my_database;
To know which database is currently in use
Listing all Databases
We can use LIKE to filter the listing of database
This will list all databases having plus2 any where in the database name.
SHOW databases LIKE '%plus2%';
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.
With this our my_database is available to us.
In windows we can refer the database or the table names in upper or lower case as there is no restriction on case, but under UNIX system all names are case-sensitive.
If the database is not available then this will generate error, so we can check before deleting.
DROP DATABASE my_database;
DROP DATABASE IF EXISTS my_database;
PHP Script to List all Databases
SQL Show all tables in DatabaseHow to delete table or database
This article is written by plus2net.com team.
▼ More on Math functions in SQL