From the course: PostgreSQL Essential Training

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Automatically fill in default values

Automatically fill in default values - PostgreSQL Tutorial

From the course: PostgreSQL Essential Training

Automatically fill in default values

- [Instructor] Sometimes you'll have a column in a table that'll normally store the same value for most records that get entered. You can specify a column's default value to help speed up data entry tasks, and that value will get applied to all new records automatically, unless you type in something else. Let's take a look at how this works by adding a default value to the Kineteco products table. Let's first review the data that's in the related categories table, though. I'll select it and then click the view data button. Right now we have five different categories of products that are manufactured. I want to assume that most new products belong in the solar panel category. That's the one with the category ID number four. We can suggest this number automatically in the products table when we enter in new products. We do that by altering the foreign key column in the products table. That's the category ID column over…

Contents