Files
freeCodeCamp/guide/english/sql/sql-insert-query/index.md
2019-06-28 00:21:21 -07:00

44 lines
738 B
Markdown

---
title: SQL Insert Query
---
## SQL Insert Query
Insert queries are a way to insert data into a table. Let's say we have created a table using
```sql
CREATE TABLE example_table ( name varchar(255), age int)
```
**example_table**
| Name | Age |
| --- | --- |
Now to add some data to this table , we'll use **INSERT** in the following way:
```sql
INSERT INTO example_table (column1,column2) VALUES ("Andrew",23)
```
**example_table**
| Name | Age |
| --- | --- |
| Andrew | 23 |
Even the following will work, but it's always a good practice to specify which data is going into which column.
```sql
INSERT INTO table_name VALUES ("John", 28)
```
**example_table**
| Name | Age |
| --- | --- |
| Andrew | 23 |
| John | 28 |