SQL Insert Into
The SQL INSERT INTO statement is used to insert new records or rows into a database table. Here’s the general syntax:
sql
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
Let’s break down the syntax:
- INSERT INTO: This keyword is used to specify that you want to insert data into a table.
- table_name: This is the name of the table where you want to insert the data.
- column1, column2, column3, …: These are the names of the columns in the table where you want to insert the data. If you’re inserting data into all columns, you can omit this part.
- VALUES: This keyword indicates that you’re specifying the values to be inserted.
- value1, value2, value3, …: These are the actual values you want to insert into the corresponding columns. The order of the values should match the order of the columns specified.
Here’s an example that demonstrates how to use the INSERT INTO statement:
sql
INSERT INTO employees (id, name, age, salary)
VALUES (1, 'John Doe', 30, 50000);
In this example, we’re inserting a new record into the “employees” table. We specify the values for the “id”, “name”, “age”, and “salary” columns.
Note that the specific syntax may vary slightly depending on the database management system (DBMS) you’re using.