SQL INSERT Statement
The SQL INSERT statement is used to insert a single or multiple data in a table. In SQL, You can insert the data in two ways:
- Without specifying column name
- By specifying column name
Sample Table
EMPLOYEE
EMP_ID | EMP_NAME | CITY | SALARY | AGE |
---|---|---|---|---|
1 | Angelina | Chicago | 200000 | 30 |
2 | Robert | Austin | 300000 | 26 |
3 | Christian | Denver | 100000 | 42 |
4 | Kristen | Washington | 500000 | 29 |
5 | Russell | Los angels | 200000 | 36 |
1. Without specifying column name
If you want to specify all column values, you can specify or ignore the column values.
Syntax
Query
Output: After executing this query, the EMPLOYEE table will look like:
EMP_ID | EMP_NAME | CITY | SALARY | AGE |
---|---|---|---|---|
1 | Angelina | Chicago | 200000 | 30 |
2 | Robert | Austin | 300000 | 26 |
3 | Christian | Denver | 100000 | 42 |
4 | Kristen | Washington | 500000 | 29 |
5 | Russell | Los angels | 200000 | 36 |
6 | Marry | Canada | 600000 | 48 |
2. By specifying column name
To insert partial column values, you must have to specify the column names.
Syntax
Query
Output: After executing this query, the table will look like:
EMP_ID | EMP_NAME | CITY | SALARY | AGE |
---|---|---|---|---|
1 | Angelina | Chicago | 200000 | 30 |
2 | Robert | Austin | 300000 | 26 |
3 | Christian | Denver | 100000 | 42 |
4 | Kristen | Washington | 500000 | 29 |
5 | Russell | Los angels | 200000 | 36 |
6 | Marry | Canada | 600000 | 48 |
7 | Jack | null | null | 40 |
0 Comments