Re: How to covert 'char' to 'inet'
От | Darren Ferguson |
---|---|
Тема | Re: How to covert 'char' to 'inet' |
Дата | |
Msg-id | Pine.LNX.4.44.0207251017410.32008-100000@thread.crystalballinc.com обсуждение исходный текст |
Ответ на | Re: How to covert 'char' to 'inet' (Andrew Sullivan <andrew@libertyrms.info>) |
Ответы |
Re: How to covert 'char' to 'inet'
|
Список | pgsql-general |
If you are using IP addresses then Postgres has some really nice IP related datatypes and functions such as INET I would definately be inclined to use these instead of char() and varchar(). Darren On Thu, 25 Jul 2002, Andrew Sullivan wrote: > On Wed, Jul 24, 2002 at 01:40:01AM -0700, Michal O wrote: > > Thank you. What I did was: > > > > inet(trim(both ' ' from server_ip::text)) > > > > and worked fine. Convertion to 'text' was needed. > > Do you know how time consuming it is ? Is there more efficient way ? > > No, as I say, char() is padded, and spaces (or whatever) are not > legal in IP addresses. So, if you have a char field with data > 10.0.0.1, its actual representation is something more like > '10.0.0.1_______', where '_' is the padding. This is the same > problem you would have if you inserted the char() field into a > newly-created varchar() field: you'd get the padded text instead. > That's a reason to avoid using char() for most cases, unless you know > that the field will _always_ be the same length. > > A > > -- Darren Ferguson
В списке pgsql-general по дате отправления: