manage mysql database server code example
Example: Manage Database in MySQL
Before doing anything else with the data, you need to create a database. A database is a container of data. It stores contacts, vendors, customers or any kind of data that you can think of.
In MySQL, a database is a collection of objects that are used to store and manipulate data such as tables, database views, triggers, and stored procedures.
To create a database in MySQL, you use the CREATE DATABASE statement as follows:
CREATE DATABASE [IF NOT EXISTS] database_name;
Let’s examine the CREATE DATABASE statement in greater detail:
Followed by the CREATE DATABASE statement is database name that you want to create. It is recommended that the database name should be as meaningful and descriptive as possible.
The IF NOT EXISTS is an optional clause of the statement. The IF NOT EXISTS clause prevents you from an error of creating a new database that already exists in the database server. You cannot have 2 databases with the same name in a MySQL database server.