Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to convert enums to text in PostgreSQL

Is is possible to convert an enum declared in a postgresql schema to text so that I could use like clause for the enum column?

like image 578
Blip Avatar asked Jul 09 '16 08:07

Blip


Video Answer


1 Answers

You can cast the enum into text easily and use any textual operators on it.

select * FROM table WHERE enumfield::text LIKE 'Some%';

There might be a better way to handle what you want to achieve though since the performance of this isn't the best.

like image 170
Sami Kuhmonen Avatar answered Oct 27 '22 20:10

Sami Kuhmonen