Sintaxis
psql BASEDEDATOS USUARIO << EOF
declaracion 1;
declaracion 2;
.
.
declaracion n;
EOF
PostgreSQL: Ejecutando SQL desde código Shell
Provee todos los comandos postgreSQL entre el bloque EOF
#!/bin/sh
bd="test"
usuario="test"
psql $db $usuario << EOF
SELECT * FROM test;
EOF
PostgreSQL: Usando Variables en SQL en un código Shell
Puedes usar variables shell dentro del bloque EOF
#!/bin/sh
db="test"
usuario="test"
cond="tgs"
psql $db $usuario << EOF
SELECT * FROM test WHERE col_name = '$cond';
EOF
No hay comentarios:
Publicar un comentario