SQL - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQL Insert

SQL Insert

shape Description

By using SQL Insert command new record can be inserted in the existing database table. i.e, inserting field value like emp_id, emp_name and salary can be inserted.

shape Conceptual figure

shape Syntax

Insert into <table_name> values(<value1>,<value2>,<value3>.......);
Table name =>The accurate table. values =>values are the column values.

shape Examples

By viewing the below example, the concept of insert command can be understood easily. [c]sql> create table employee(emp_id number(4),ename varchar2(20),sal number); Query OK, 0 rows affected (0.32 sec) sql> insert into employee values(1001,'jack',12000); ERROR 1146 (42S02): Table 'employee.employee' doesn't exist sql> create table employee(emp_id number(4),ename varchar2(20),sal number); Query OK, 0 rows affected (0.63 sec) sql> insert into employee values(1001,'jack',12000); Query OK, 1 row affected (0.10 sec) sql> insert into employee values(1002,'mack',13000); Query OK, 1 row affected (0.39 sec) sql> select * from employee; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1001 | jack | 12000 | | 1002 | mack | 13000 | +--------+-------+-------+ 2 rows in set (0.00 sec) sql>insert into employee values(1003,'james',15000); Query Ok, 1 row affected (0.39) sql>insert into employee values(1004,'Kim',17000); Query Ok, 1 row affected (0.39) sql> select * from employee; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1001 | jack | 12000 | | 1002 | mack | 13000 | | 1003 | james | 15000 | | 1004 | Kim | 17000 | +--------+-------+-------+ 2 rows in set (0.00 sec)[/c] The above example tells that, when insert command is performed on the table employee then it will accept the values and stores in the table database.

Summary

shape Key Points

  • SQL INSERT Statement - SQL INSERT Statement is utilized to insert the values inside the table.