MySQL Creating and Deleting Database
In this section you will learn how to create and delete the database in MySQL. MySQL provides the both commands. In this section you can learn the following things :- Creation and Selection of database
- Creation of table
- Load the data into the table
mysql> SHOW DATABASES; |
Creating And Selecting a Database
mysql>CREATE DATABASE search; |
Creating a database does not mean that it is select for use, you have to select it explicitly by the USE command.
mysql> USE search |
MySQL Creating Table Creating a database is very easy part but at this point you want the list of tables by SHOW TABLES statement it shows empty.
mysql> SHOW TABLES; Empty set (0.00sec) |
mysql>create table Emp (fname VARCHAR(20), lname VARCHAR(20), city VARCHAR(20), ->sex CHAR(1), bod DATE); |
mysql>DESCRIBE Emp; |
mysql>INSERT INTO Emp VALUES('Amar', 'Patel', 'Delhi', 'M', '14-02-2004'); |
SELECT column_names FROM table_nameWHERE condition_to_satisfy |
mysql> SELECT * FROM Emp; mysql> SELECT fname,lname FROM Emp; mysql> SELECT * FROM Emp WHERE fname='Amar'; |
If you need to delete the database then you have to use the DROP statement. Example -
mysql> DROP DATABASE search; |
CREATE USER user_name [IDENTIFIED BY[password] 'password']
Create User statement is used to create a new MySQL account. For using this statement you must have the global CREATE USER privilege or the INSERT privilege for the mysql database.
MySQL drop User syntax:The DROP USER statement is used to delete the one or more MySQL accounts. But you must have the global CREATE USER privilege or DELETE privilege for the mysql database. The general syntax to drop user is :
DROP USER user_name; |
No comments:
Post a Comment