How to create show open delete database in mysql using cmd - In this article I will share a tutorial on how to create a database, show a database list, open a database and delete a database in mysql using cmd.
CREATE DATABASE [IF NOT EXISTS] database_name;
The above command will create a new database named database_name. The naming rules of a database are the same as the naming rules of a variable, where in general the database name may consist of letters, numbers and under-scores (_). If the database to be created already exists, then the error message will appear. But if you want to automatically delete the old database if it already exists, enable the option IF NOT EXISTS.Setiap we create a new database, then MySQL will actually create a folder (directory) in accordance with the name of the database is placed by default in C:\mysql\data. Inside the folder will be there are files associated with the table in the database.
Here's an example of a command to create a new database named " student":
CREATE DATABASE student;
If the above query is executed successfully and the database is successfully created, it will
Displayed message as follows:
Query OK, 1 row affected (0.02 sec)
SHOW DATABASES;
The results of the above command will show all the databases already in MySQL. Here is an example of the results from the above query:
USE student;
If the above command or query is successful, it will display the message as follows:
Database changed
DROP DATABASE [IF EXISTS] database_name;
The above command will delete the database with nama_database name. If the database exists then the database and also all the tables in it will be deleted. So be careful with this command! If the name of the database to be deleted is not found, it will display an error message. Enable the IF EXISTS option to ensure that a database exists.
Here's an example of a command to delete a database named "student":
DROP DATABASE student;
That is How to create show open delete database in mysql using cmd. Hopefully can increase your knowledge in learning mysql database. Thank you for visiting this php programming language blog.
How to create database in mysql using cmd
The general syntax of SQL to create a database is as follows:CREATE DATABASE [IF NOT EXISTS] database_name;
The above command will create a new database named database_name. The naming rules of a database are the same as the naming rules of a variable, where in general the database name may consist of letters, numbers and under-scores (_). If the database to be created already exists, then the error message will appear. But if you want to automatically delete the old database if it already exists, enable the option IF NOT EXISTS.Setiap we create a new database, then MySQL will actually create a folder (directory) in accordance with the name of the database is placed by default in C:\mysql\data. Inside the folder will be there are files associated with the table in the database.
Here's an example of a command to create a new database named " student":
CREATE DATABASE student;
If the above query is executed successfully and the database is successfully created, it will
Displayed message as follows:
Query OK, 1 row affected (0.02 sec)
How to show database in mysql using cmd
To view newly created or existing databases, use the following command:SHOW DATABASES;
The results of the above command will show all the databases already in MySQL. Here is an example of the results from the above query:
How to open mysql database using cmd
Before manipulating the tables and records that are in it, we must open or activate the database first. To open the "student" database, here is the query:USE student;
If the above command or query is successful, it will display the message as follows:
Database changed
How to delete database in mysql using command prompt
To delete a database, the general syntax is as follows:DROP DATABASE [IF EXISTS] database_name;
The above command will delete the database with nama_database name. If the database exists then the database and also all the tables in it will be deleted. So be careful with this command! If the name of the database to be deleted is not found, it will display an error message. Enable the IF EXISTS option to ensure that a database exists.
Here's an example of a command to delete a database named "student":
DROP DATABASE student;
That is How to create show open delete database in mysql using cmd. Hopefully can increase your knowledge in learning mysql database. Thank you for visiting this php programming language blog.
Comments
Post a Comment