SQL Database


1) SQL - Show all databases

To show all the databases created in the database management system.


Syntax -

show databases;

sql show all databases


2) SQL - Create a database

To create a database in which all related data will be stored.


Syntax -

create database database_name ;

sql create databases


3) SQL - Delete (drop) database

To delete a database for many created databases.


Syntax -

drop database database_name ;

sql delete (drop) database


4) SQL - Check current database

To check the current database in which we are currently working.


Syntax -

select database();

sql current databases


5) SQL- Use a database

To use a database in which we need to create table or modify the table.


Syntax -

use database_name ;

sql use database


6) SQL - Null vs Not null

Null means when we do not enter any value in any column then in this place of value it shows NULL.

It does not need any tag (it entered by default).

sql null vs not null


AND

 

NOT NULL means when we do not enter any value in any column then there automatically inserted zero.


Syntax -

create table table_name ( 

column1_name data_type(range) not null ,

column2_name data_type(range) ,

.......

 );

sql null vs not null


7) SQL - Default value

The default value means when we do not enter any value in any column then there we can use a custom default value.

 

Syntax -

create table table_name ( 

column1_name data_type(range) default'type default value what to show' ,

column_name data_type(range) ,

....

);

sql default value