On 12-05-2012 08:59, Erison Gmail wrote:
>
>> Tente isto: o comando xxd faz um hex dump do arquivo binário, é preciso
>> sanitizar o fim de linha com o tr, por exemplo, jogar a saída disso tudo
>> para o psql carregar na sua tabela com COPY:
>
>> xxd -p /caminho/arquivo | tr -d '\n' | psql -c "COPY sua_tabela FROM
>> stdin;"
>
>> Tentaí.
>
>
>> Tente também:
>
>> INSERT INTO sua_tabela VALUES (1, 2, SELECT
>> pg_read_binary_file('/caminho/foo'));
>> Obs: neste caso, o usuário do servidor deve ter permissões de acesso ao
>> arquivo.
>
> E quanto a recuperação?

O comando xxd faz as duas coisas, converter binário em hex e vice-versa.
psql -c "SELECT coluna_bytea WHERE suas_restricoes LIMIT 1;" | xxd - 
arquivo.bin

Precisa tentar, eu não testei aqui. Mas deve funcionar.
Não existe uma função "pg_write_binary_file" e a função 
pg_read_binary_file é exclusiva a superusuários.

[]s

Flavio Henrique A. Gurgel
Consultor e Instrutor 4Linux
Tel: +55-11-2125-4747
www.4linux.com.br
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a