Re: Best Type to use - Mailing list pgsql-novice

From Kevin Crenshaw
Subject Re: Best Type to use
Date
Msg-id 20060105201007.2340D9DC812@postgresql.org
Whole thread Raw
In response to Best Type to use  (Ketema Harris <ketema@gmail.com>)
Responses Re: Best Type to use
List pgsql-novice

You can also use the TEXT data type.  Just convert your binary data to base64 and write it to a field in your database like you would any other type of text.  This method takes up more space than the other methods but it avoids some of the headaches of dealing with bytea.

 

CREATE OR REPLACE FUNCTION SAVE_TCP_DUMP(TEXT) RETURNS VOID AS $$

      BEGIN

            INSERT INTO mytable(tcpdump) VALUES($1);

      END;

$$ LANGUAGE ‘plpgsql’;

 

 

HTH,

Kevin

 

 

 


From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Ketema Harris
Sent: Thursday, January 05, 2006 2:19 PM
To: pgsql-novice@postgresql.org
Subject: [NOVICE] Best Type to use

 

Hi, I would like to store binary data from a tcpdump (libpcap) file in a table.  What is the best type to use?  i have read posts saying lo, oid, and bytea.  Which one would be best for this scenario?  Depending on the type can a sample insert and select statement be given as well?

Thanks,

ketema

pgsql-novice by date:

Previous
From: Ketema Harris
Date:
Subject: Best Type to use
Next
From:
Date:
Subject: index over boolean fields?