Drop command: To eliminate a column from a table.

To eliminate a column from table we use drop command. Suppose we have table employee with an extra field Address and we want to eliminate this.

To remove this column we use Drop query.


How to add new column in a table?

To insert new column in a table we use ALTER query.


For example, if we consider the table employee we can write the query as:

by this query we see that a new column E_City has been added in table Employee.Further you can also insert values in column city by using update query.
insertion of a new column

Insertion of a new record in a table

To insert a new record in a table we use Insert Query.

To insert all fields value in table we use following insert query

To insert all or selected fields value in table we use following insert query

We have created a table student as below

To insert record in above table we use insert query like below

to insert specific column value we have to provide column name in insert query

here we have not provided any value for id column because id is auto increment column so it will automatically increment id column value one by one.
To see inserted values in table we use

We have not provided value for few fields that is showing null.

MySql Update Table

To update records in a table we use update quey


First select the table data

by this query we get a table ‘student’ which we have created in our database as shown above.

To update the above table, we use the query:

we can see the updated table

If you don’t use where clause in query then it will update all the record of fields with given value
We can update multiple column value in single query.

The updated table is

MySql Select Query

To select all records from a table we use following query


To select all row of student we use

It will show following result

To select perticular column from table we use

If we want to select id and name of student the we will write

ther is no limit we can select one to all column by specifying the column name.
We can also select table detail based on some criteria for that we use following query

We want to fetch all record of student whose id is 1.
for that we write

If you want to fetch detail of student whose age is 10
for that we will use

where can also set multiple condition with where clause

Selecting column with null value we write following query

To check for null value we use is null with field name.

MySql Select Database

Suppose you have created database, to use it , write query:


If we want to select ebhor database then use following query

with the help of this query you can work on your created database.

MySql Create New Database

To create database use following query:


To create a database with name ebhor use following query

This query will create a new database.

MySql Show all databases

To see all the created  databases we use show database query



It will show all the databases created in mysql.