SQL Insert Into

Galaxy Glossary

How do you add new data to a table in SQL?

The `INSERT INTO` statement is fundamental in SQL for adding new rows of data to a table. It's a crucial part of data management, allowing you to populate your database with information. This statement specifies the table and the values to be inserted.
Sign up for the latest in SQL knowledge from the Galaxy Team!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Description

The `INSERT INTO` statement is used to add new rows to a table in a relational database. It's a core part of data manipulation, enabling you to populate your database with the necessary information. This statement is essential for creating and maintaining the data within your tables. Understanding how to use `INSERT INTO` correctly is vital for any SQL developer. It's a straightforward yet powerful tool for adding data, enabling you to update and maintain your database effectively. The statement takes the table name as input and allows you to specify the values to be inserted into the columns of that table.

Why SQL Insert Into is important

The `INSERT INTO` statement is crucial for populating databases with data. Without it, you wouldn't be able to add new records, making the database useless. It's a fundamental building block for any data-driven application.

Example Usage


-- SQL Server example
CREATE TABLE Customers (
    CustomerID INT PRIMARY KEY,
    FirstName VARCHAR(50),
    LastName VARCHAR(50)
);
GO
INSERT INTO Customers (CustomerID, FirstName, LastName)
VALUES (1, 'John', 'Doe');
GO
INSERT INTO Customers (CustomerID, FirstName, LastName)
VALUES (2, 'Jane', 'Smith');
GO
SELECT * FROM Customers;

Common Mistakes

Want to learn about other SQL terms?