executing query results withing psql

Поиск
Список
Период
Сортировка
От Reece Hart
Тема executing query results withing psql
Дата
Msg-id 1204727393.6406.68.camel@snafu
обсуждение исходный текст
Список pgsql-general
Is there a way to generate and directly execute query results within
psql? Essentially, I want eval within psql.

For example, a lot of us generate DDL commands using queries, like this:
        => SELECT 'GRANT SELECT ON VIEW "'||table_schema||'.'||
        table_name||'" TO budget_view;'
        FROM information_schema.views
        WHERE table_schema='budget';

To execute such results, I do one these:
* in a shell, pipe between psqls (ie, psql -Atc 'select ...' | psql)
* within psql, execute and copy-paste
* within psql, use \g file, then \i file
* within psql, use \g |psql

I like the \g + \i option most for consistency and robustness (don't
have to specify the db connection or worry about connecting to the wrong
db), but what I really want is a hypothetical \eval to execute the query
and then execute the results.

Any such thing?

Thanks,
Reece

--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0


В списке pgsql-general по дате отправления:

Предыдущее
От: "pobox@verysmall.org"
Дата:
Сообщение: PostgreSQL vs. MySQL benchmarks on SMP FreeBSD 7.0
Следующее
От: David Fetter
Дата:
Сообщение: Re: [DOCS] Documenting a DB schema