Files
freeCodeCamp/guide/english/sql/sql-insert-query/index.md

44 lines
738 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
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)
```
2018-10-12 15:37:13 -04:00
**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)
```
2018-10-12 15:37:13 -04:00
**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)
```
2018-10-12 15:37:13 -04:00
**example_table**
| Name | Age |
| --- | --- |
| Andrew | 23 |
| John | 28 |