SQL – INSERT
SQL – INSERT Statement:
SQL INSERT INTO Statement is used to insert a new row(ie. record) in a table.
SQL INSERT INTO Syntax:
INSERT INTO TableName VALUES(Value1,Value2,….);
Note: The Above Syntax inserts rows in all columns of the table.
If You want to insert values in selected columns the following syntax is used :
INSERT INTO TableName (ColumnName1,ColumnName2,….)VALUES(Value1,Value2,….);
EXAMPLE 1 (Insert in all column) :
Example
INSERT INTO Users VALUES(‘1′,’John’,’john@yahoo.com’,’USA’,’NewYork’);
1 New row will be inserted.
Now the table has its first record after the selection it will show:
EXAMPLE 2 (Insert in few columns only):
Example
INSERT INTO Users (ID,Name,Email)VALUES(‘2′,’Devid’,’david@yahoo.com’);
Note: We need to specify the column name in which we want to insert values Like If want to insert values in ID, Name and Email Columns only…
Now the table will look like:
Advertisements
Add Comment
📖 Read More
- 1. SQL - SELECT
- 2. SQL - WHERE Clause
- 3. SQL - AND & OR
- 4. SQL ORDER BY
- 5. SQL - UPDATE
- 6. SQL - DELETE
- 7. SQL - Like
- 8. SQL In Operator
- 9. SQL Between
- 10. SQL Joins - INNER JOIN