"if you encounter any errors in SAP, send me a screenshot at pramod@learntosap.com, and I will help you resolve the issue."

SQL INSERT INTO Statement – Step-by-Step Complete Guide (With Examples)

SQL TUTORIALS-

SQL INSERT INTO Statement

Introduction-


Trulli Trulli

🔍SQL INSERT INTO – Explanation with Example AND How to use SQL INSERT INTO statement

SQL INSERT INTO statement is used to insert new records into a table...

✅ 1-If specifies the table name and the values to be inserted into its columns. You can either insert values into all columns or specify certain columns only.basic syntax is Follow:-


INSERT INTO table_name
VALUES (value1, value2, value3, ...);

✅ 2-If inserting into all columns, don’t need to write the column names in the INSERT INTO statement if you're providing values for all the columns in the exact order they are defined in the table..basic syntax is Follow:-




INSERT INTO table_name VALUES (value1, value2);

Emoji Examples in HTML

🔸 Example Table: Employees

ID Name Department Salary
1 ANNI IT 10000
2 POOJA IT 9000
3 RAJ SALES 5000

✅ Example 1: Insert full values in all columns:-


INSERT INTO Employees (ID, Name, Department, Salary)
VALUES (4, 'MAYA', 'HR', 11000);

Row inserted → 4 | MAYA | HR | 11000

Result Show :-

Emoji Examples in HTML

🔸 Example Table: Employees


ID Name Department Salary
1 ANNI IT 10000
2 POOJA IT 9000
3 RAJ SALES 5000
4 MAYA HR 11000

✅ Example 2: Insert (ONE MORE) another record:-

SELECT Query :-


INSERT INTO Employees (ID, Name, Department, Salary)
VALUES (5, 'NILESH', 'HR', 7000);

Row inserted → 5 | NILESH | HR | 7000

Result Show :-

Emoji Examples in HTML

🔸 Example Table: Employees

ID Name Department Salary
1 ANNI IT 10000
2 POOJA IT 9000
3 RAJ SALES 5000
4 MAYA HR 11000
5 NILESH HR 7000

✅ Example 3: Insert without column name (column order must match this table):-

SELECT Query :-


INSERT INTO Employees
VALUES (6, 'PRAMOD', 'IT', 12000);

Row inserted → 6 | PRAMOD | IT | 12000

Result Show :-

Emoji Examples in HTML

🔸 Example Table: Employees

ID Name Department Salary
1 ANNI IT 10000
2 POOJA IT 9000
3 RAJ SALES 5000
4 MAYA HR 11000
5 NILESH HR 7000
6 PRAMOD IT 12000

May Be Like Important Link-

-SQL Tutorial for Beginners – Introduction to SQL

-SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause

-SQL SELECT DISTINCT Statement Clause Explained with Examples

-SQL Wildcard Characters: Complete Guide with Examples