SQL BASICS:

First goto this folder

Connectivity:

-u username: root

-p password:

-h host:127.0.0.1

Password: just give enter bcoz there is no password

Create database:

Create database database_name;

 

Use database;

Create Table:

 

Drop:

used to delete both the structure and record 

drop table table_name; 

drop Table:

Drop column:

ALTER TABLE "table_name"
DROP "column_name";

Before drop:

After drop:

 

Alter:

  • to add a column to existing table -add
  • to rename any existing column- rename
  • to change datatype of any column or to modify its size. -modify
  • to drop a column from the table. -drop

 

Adding multiple colums

Add Column with default value:

ALTER TABLE table_name ADD(

    column-name1 datatype1 DEFAULT some_value

);

 

Modify:

used to modify data type of any existing column

 

Alter table table_name modify column_name  new_datatype;

 

 

Rename table:

Rename a Column:

ALTER TABLE "table_name"
CHANGE "column_name" "new column_name" "New Data Type";

 

Truncate:

Before Truncate

After Truncate

Structure will be remain..

It delete the contents inside the table

So we can use this same template again to store new values

Ex:

 

 

 

 

 

 

 

Insertion:

 

Comments