mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 15:18:01 +00:00
Add Insert Just The Defaults as a postgres til.
This commit is contained in:
@@ -111,6 +111,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
||||
- [Generate A UUID](postgres/generate-a-uuid.md)
|
||||
- [Generate Series Of Numbers](postgres/generate-series-of-numbers.md)
|
||||
- [Getting A Slice Of An Array](postgres/getting-a-slice-of-an-array.md)
|
||||
- [Insert Just The Defaults](postgres/insert-just-the-defaults.md)
|
||||
- [Integers In Postgres](postgres/integers-in-postgres.md)
|
||||
- [Intervals Of Time By Week](postgres/intervals-of-time-by-week.md)
|
||||
- [Limit Execution Time Of Statements](postgres/limit-execution-time-of-statements.md)
|
||||
|
||||
15
postgres/insert-just-the-defaults.md
Normal file
15
postgres/insert-just-the-defaults.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Insert Just The Defaults
|
||||
|
||||
If you are constructing an `INSERT` statement for a table whose required
|
||||
columns all have default values, you may just want to use the defaults. In
|
||||
this situation, you can break away from the standard:
|
||||
|
||||
```
|
||||
> insert into table_name (column1, column2) values (value1, value2);
|
||||
```
|
||||
|
||||
Instead, simply tell Postgres that you want it to use the default values:
|
||||
|
||||
```
|
||||
> insert into table_name default values;
|
||||
```
|
||||
Reference in New Issue
Block a user