0
0
SQLquery~5 mins

INSERT INTO single row in SQL

Choose your learning style9 modes available
Introduction

We use INSERT INTO to add new information (a single row) into a table in a database.

Adding a new customer record to a customer list.
Saving a new product in an online store's inventory.
Recording a new employee's details in the company database.
Entering a new book into a library catalog.
Logging a new order placed by a user.
Syntax
SQL
INSERT INTO table_name (column1, column2, column3) VALUES (value1, value2, value3);

The table_name is where you want to add the data.

You list the columns and then provide matching values in the same order.

Examples
Adds one employee named Alice, age 30, working in HR.
SQL
INSERT INTO employees (name, age, department) VALUES ('Alice', 30, 'HR');
Adds a product called Notebook priced at 2.5.
SQL
INSERT INTO products (product_name, price) VALUES ('Notebook', 2.5);
Adds a customer with ID 101 and name John Doe.
SQL
INSERT INTO customers (id, name) VALUES (101, 'John Doe');
Sample Program

This creates a table called students, inserts one student named Emma with grade A, then shows all students.

SQL
CREATE TABLE students (id INT, name VARCHAR(50), grade CHAR(1));
INSERT INTO students (id, name, grade) VALUES (1, 'Emma', 'A');
SELECT * FROM students;
OutputSuccess
Important Notes

If you skip columns, you must provide values for all columns that do not allow NULL.

Text values must be in single quotes.

Always check the order of columns and values to avoid mistakes.

Summary

INSERT INTO single row adds one new record to a table.

Specify the table, columns, and matching values.

Use single quotes for text and match the order carefully.