Today I Learned

hashrocket A Hashrocket project

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;
See More #sql TILs
Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.