SQL DATABASE QUERIES 

Database : A collection of data organised in structured format

You will find all database related queries like,

  • create database

  • show database

  • select database

  • use database

Create database

Query or statement to create a database

CREATE DATABASE database_name ;

Create database Example

creating a database with name "code_calculate"

CREATE DATABASE code_calculate ;

list all databases in your dbms (database management system)

Show Databases

Query or statement to show list of all databases

SHOW DATABASES ;

Example of Show Databases 

Before creating database code_calcualte 

mysql> show databases;
+--------------------------------+
|         Database              |
+--------------------------------+
| information_schema   |
| mysql                            |
| performance_schema |
| sys                                 |
+--------------------------------+

After creating database code_calcualte 

mysql> show databases;
+--------------------------------+
|         Database              |
+--------------------------------+
| information_schema   |

| code_calculate            |
| mysql                            |
| performance_schema |
| sys                                |
+--------------------------------+

Note : Don't forgot colon(;) at end of query. Don't confuse with signs +,|,---- in the example. those are just separating content

Select Database

To check what is current database we are using,

SELECT DATABASE();

example to check present database

mysql> SELECT DATABASE();
+-------------------+
| DATABASE() |
+-------------------+
|       NULL       |
+-------------------+

Till now we are not using any database, that's why we are getting NULL, let's see how to use database

Use Database

Query to use database

USE  database_name;

we already created code_calculate database, we will use that one, query to use code_calculate database

USE  code_calculate;

Now check current database which we are using,

mysql> SELECT DATABASE();
+----------------------+
| DATABASE()     |
+----------------------+
| code_calculate |
+-----------------------+

 Contact Us:

                  codecalculatenr@gmail.com

 

About Us : 

        Code Calculate is the biggest online platform