ViewPointが保持している情報を直接確認する方法（PostgreSQL）

#目的
ViewPointで表示する情報は、dcs（Data Collection Service）がTeradataDBから取得し、内部DB（PostgreSQL）に格納したもの。
格納されている値を直接確認する。


#方法
##１．postgresユーザにスイッチ

su - postgres

```
TDExpress1620_Sles11:~ # su - postgres
postgres@TDExpress1620_Sles11:~> 
```

##２．postgreSQLを起動

psql

```
postgres@TDExpress1620_Sles11:~> psql
psql (9.4.19)
Type "help" for help.

postgres=# 
```

##３．作成済みDBを確認

\l

```
dcsdb=# \l
                                 List of databases
    Name     |  Owner   | Encoding | Collate |    Ctype    |   Access privileges   
-------------+----------+----------+---------+-------------+-----------------------
 cam         | postgres | UTF8     | C       | en_US.UTF-8 | 
 dcsdb       | postgres | UTF8     | C       | en_US.UTF-8 | =Tc/postgres         +
             |          |          |         |             | postgres=CTc/postgres+
             |          |          |         |             | dcs=C/postgres
 postgres    | postgres | UTF8     | C       | en_US.UTF-8 | 
 td_portal   | postgres | UTF8     | C       | en_US.UTF-8 | 
 td_portlets | postgres | UTF8     | C       | en_US.UTF-8 | =Tc/postgres         +
             |          |          |         |             | postgres=CTc/postgres+
             |          |          |         |             | viewpoint=C/postgres
 template0   | postgres | UTF8     | C       | en_US.UTF-8 | =c/postgres          +
             |          |          |         |             | postgres=CTc/postgres
 template1   | postgres | UTF8     | C       | en_US.UTF-8 | =c/postgres          +
             |          |          |         |             | postgres=CTc/postgres
(7 rows)
```
dcsが取得した情報はdcsdb


##４．dcsdbに接続
\c

```
dcsdb=# \c dcsdb
You are now connected to database "dcsdb" as user "postgres".
```

##５．テーブル一覧を確認

dcsdb=# \dt


 Schema |                   Name                   | Type  | Owner 
--------+------------------------------------------+-------+-------
 public | account_info                             | table | dcs
 public | application_names                        | table | dcs
 public | awt_info                                 | table | dcs
 public | awt_info_summary                         | table | dcs
 public | blocking_locks                           | table | dcs
 public | blocking_sessions                        | table | dcs
 public | bucket_range                             | table | dcs
 public | cache_database_archive_log               | table | dcs
 public | cache_database_space                     | table | dcs
 public | cache_database_space_sum                 | table | dcs
 public | canary_results                           | table | dcs
 public | collection_errors                        | table | dcs
 public | collection_errors_status                 | table | dcs
 public | collection_progress                      | table | dcs
 public | connection_pool_test                     | table | dcs
 public | database_backup_log                      | table | dcs
 public | database_space                           | table | dcs
 public | database_vacuum_log                      | table | dcs
 public | databasechangelog                        | table | dcs
 public | databasechangeloglock                    | table | dcs
 public | dbql_app_mapping                         | table | dcs
 public | dbql_detail                              | table | dcs
 public | dbql_summary                             | table | dcs
 public | disk_space                               | table | dcs
 public | elastic_tcore_tracking                   | table | dcs
 public | elastic_usage_limit                      | table | dcs
 public | elastic_usage_node                       | table | dcs
 public | elastic_usage_node_signature             | table | dcs
 public | elastic_usage_summary                    | table | dcs
 public | elastic_usage_summary_signature          | table | dcs
 public | elastic_usage_upload_history             | table | dcs
 public | file_system_space                        | table | dcs
 public | file_system_space_id000001_y2020_m01_gmt | table | dcs
 public | file_system_space_id000001_y2021_m06_gmt | table | dcs
 public | incremental_backup_info                  | table | dcs
 public | lock_info                                | table | dcs
 public | max_data_logtime                         | table | dcs
 public | pdcr_job_details                         | table | dcs
 public | pdcr_job_sql_log                         | table | dcs
 public | pdcr_job_summary                         | table | dcs
 public | physical_resources                       | table | dcs
 public | physical_resources_extended              | table | dcs
 public | query_log                                | table | dcs
 public | query_log_query_band                     | table | dcs
 public | resource_usage_node                      | table | dcs
 public | resource_usage_vproc                     | table | dcs
 public | session_explain                          | table | dcs
public | session_query_band                       | table | dcs
 public | session_request                          | table | dcs
 public | session_steps                            | table | dcs
 public | sessions                                 | table | dcs
 public | sessions_extended                        | table | dcs
 public | sessions_summary                         | table | dcs
 public | sessions_with_system_name                | table | dcs
 public | system_health                            | table | dcs
 public | system_statistics                        | table | dcs
 public | system_type                              | table | dcs
 public | system_versions                          | table | dcs
 public | table_space                              | table | dcs
 public | tdstats_analyze_job_history              | table | dcs
 public | tdstats_analyze_reports                  | table | dcs
 public | tdstats_automate_reports                 | table | dcs
 public | tdstats_cleanup_reports                  | table | dcs
 public | tdstats_collect_job_history              | table | dcs
 public | tdstats_collect_reports                  | table | dcs
 public | tdstats_job_history                      | table | dcs
 public | tdwm_control_status                      | table | dcs
 public | tdwm_delayed_statistics                  | table | dcs
 public | tdwm_eventstatus                         | table | dcs
 public | tdwm_eventstatus_combo                   | table | dcs
 public | tdwm_exception                           | table | dcs
 public | tdwm_monitor_wd                          | table | dcs
 public | tdwm_ruleset_changes                     | table | dcs
 public | tdwm_throttle_counts                     | table | dcs
 public | tdwm_utility_statistics                  | table | dcs
 public | tdwmdistribution                         | table | dcs
 public | tdwmperiod                               | table | dcs
 public | tdwmstatistics                           | table | dcs
 public | tdwmsummary                              | table | dcs
 public | tdwmsysregstatus                         | table | dcs
 public | teradata_database_info                   | table | dcs
 public | tms_stats                                | table | dcs
 public | virtual_resources                        | table | dcs
 public | virtual_resources_extended               | table | dcs
 public | virtual_resources_summary                | table | dcs
 public | virtual_storage_info                     | table | dcs
 public | vproc_space                              | table | dcs
(87 rows)

同じテーブル構成で、特定時期の情報のみ格納されたテーブルがある。

（例）

| テーブル名 | 格納されている情報の時期  |
|:-:|:-:|
| file_system_space  |  全期間の情報 |
| file_system_space_id000001_y2021_m06_gmt  | 2021年6月の情報  |



##６．テーブルの中身を確認

```
dcsdb=# select * from public.file_system_space_id000001_y2021_m06_gmt;
 id |          logtime           | datapartitionfreespace 
----+----------------------------+------------------------
  1 | 2021-06-20 09:43:32.889-04 |           135127830528
  1 | 2021-06-20 10:43:32.485-04 |           135126372352
(2 rows)
```

以上