INSERT Query Example for Mysql Database

Insert Query is used to create a new record  of data in your database table.Insert query can be performed in two ways

1.Without column names - Quick operation but problem when you add the new table columns
2.With column names- No problem when you add the new table columns

Example Table : For your reference


Table Name : Human



Human
Id Gender Age Name
1 Male 18 Sam Anderson
2 Female 24 Samoel
3 Male 16 Jamen
4 Male 26 Kamel
5 Female 32 Jami

The above table name is Human and it has four columns likely named Id, Gender, Age and Name  and it has five rows or records and if you want to insert new record then use Mysql Insert query

Syntax

Query : INSERT INTO table_name VALUES ( value1, value2,...)

or

Query : INSERT INTO table_name (Column1,Column2,...) VALUES ( value1, value2,...)

1.Without column names - INSERT QUERY

Query : INSERT INTO human VALUES ( 6, 'Male', 20, 'Blogger')



2.With column names - INSERT QUERY

Query : INSERT INTO human (Id,Gender,Age,Name)  VALUES ( 6, 'Male', 20, 'Blogger')


After executing the above query with columns or without columns then data will be persisted to human table.


Human
Id Gender Age Name
1 Male 18 Sam Anderson
2 Female 24 Samoel
3 Male 16 Jamen
4 Male 26 Kamel
5 Female 32 Jami
6 Male 20 Blogger




Comments

Popular posts from this blog

Database Multi Language Support Format

Five More Indian Languages - Google Translate