カテゴリー : db

このカテゴリーの登録数:1件 表示 : 1 - 1 / 1

2005/11/30

ポスグレが吐いてるクエリを知る

ポスト @ 14:25:20 , 修正 @ 2005/11/30 15:11:33 | , , ,     

psql -E -U postgresのように -E で入る。
ref - [PHP-users 559] Re: PostgreSQLのテーブル一覧の取得

postgres@linux:~> psql -E test
Welcome to psql 8.0.3, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

test=# \d
********* QUERY **********
SELECT n.nspname as "Schema",
  c.relname as "Name",
  CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' END as "Type",
  u.usename as "Owner"
FROM pg_catalog.pg_class c
     LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner
     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
      AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
      AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
**************************

        List of relations
 Schema | Name | Type  |  Owner
--------+------+-------+----------
 public | cd   | table | postgres
(1 row)

MySQLで。

nowel@linux:~/workspace/S2Dao.PHP5> mysql -u root -p -E
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.1.10a-Max

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
*************************** 1. row ***************************
Database: hoge
*************************** 2. row ***************************
Database: mysql
*************************** 3. row ***************************
Database: pblog
*************************** 4. row ***************************
Database: s2con
*************************** 5. row ***************************
Database: test
5 rows in set (0.00 sec)

mysql> use s2con
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
*************************** 1. row ***************************
Tables_in_s2con: CD
*************************** 2. row ***************************
Tables_in_s2con: DEPT
*************************** 3. row ***************************
Tables_in_s2con: EMP
3 rows in set (0.02 sec)