Search Postgresql Archives

cast bytea to macaddr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings Pg folks,

I have a database schema (not mine) that uses bytea to represent a MAC address. I'd like to create a view that casts that field into a MACADDR type.

# \d lease4
                           Table "public.lease4"
     Column     │           Type           │ Collation │ Nullable │ Default
════════════════╪══════════════════════════╪═══════════╪══════════╪═════════
 hwaddr         │ bytea                    │           │          │

# select hwaddr from lease4;
     hwaddr    
════════════════
 \x9cebe803e3b9

It looks like I can cast the bytea to text and then manipulate that and finally cast it to macaddr.

Is there a better, or more canonical, way to convert/cast this field?

Thanks for any help!

-m

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux