=> SELECT * FROM information_schema.tables
Essa query busca todas informações sobre o banco a qual está conectado, ou seja, nome_db, nome_schema e nome_tabela.
=>SELECT * FROM information_schema.tables WHERE table_schema='nome_do_schema'
Traz todas tabelas relacionadas ao schema informado nesta query.
=> SELECT current_database(); current_database ------------------ template1
=> select schema_name from information_schema.schemata
{retorna nome de todos schemas do banco que está conectado}
=> SELECT current_schema(); current_schema ---------------- public => SELECT current_schemas(TRUE); current_schemas --------------------- {pg_catalog,public} => SELECT CURRENT_USER AS usuario; usuario ---------- postgres => SELECT inet_client_addr(); inet_client_addr ------------------ 192.168.75.1 => template1=# SELECT inet_client_port(); inet_client_port ------------------ 16522 => SELECT inet_server_addr(); inet_server_addr ------------------ 192.168.75.128 => SELECT inet_server_port(); inet_server_port ------------------ 5432 => SELECT SESSION_USER as usuario; usuario ---------- postgres => SELECT USER as usuario; usuario ---------- postgres => SELECT version() AS versao; versao ----------------------------------------------------------------------------------------- PostgreSQL 8.0.0 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.4.2 (mingw-special)
0 comentários:
Postar um comentário