diff --git a/README.md b/README.md index 98deb1c..e84474b 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/postgres/insert-just-the-defaults.md b/postgres/insert-just-the-defaults.md new file mode 100644 index 0000000..a17dbed --- /dev/null +++ b/postgres/insert-just-the-defaults.md @@ -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; +```