课程: Supabase Essential Training

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Enum fields

Enum fields

- [Instructor] PostgreSQL provides a lot of options for column types. But what if you want something that's even more specific? Let's say we wanted to add a heat column to the items table to track stovetop cooking temperatures. We would only want values like low, medium low, medium, medium high and high. We don't want to set a specific temperature because that's not commonly supported on cooktops. Instead, we want an enumerated type or an enum for short. This enum will include just those five options and nothing else. Once we've defined that enum, then we can add it as a column here in the items table. First, go to the database section and then go to enumerated types. And now we're going to define this type. We're in the public schema, and that way it'll be accessible to our table. And I'm going to create this type. I'm going to name it heat, and I'm going to describe it as stovetop cooking temperatures. And now I'm going to add several values. I'm going to start with low, medium low,…

内容