Skip to content
Advertisement

Define enum as the column names of table PostgreSQL

Is there a way to define an enum using a table’s column names?

I have a users table defined as follows:

And then I want to define a required_profile_fields column in another table to be an enum containing only the column names in that public.users table:

Is there a way that I can define that profile_fields as an enum from the column names in public.users?

Advertisement

Answer

You can try something like this:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement