playboy=> d test; //相当于mysql的,mysql> desc test;
Table "public.test"
Column | Type | Modifiers
--------+-----------------------+-----------
id | integer | not null
name | character varying(32) |
Indexes: "playboy_id_pk" PRIMARY KEY, btree (id)
playboy=> select pg_relation_size('test'); //查看表大小
pg_relation_size
------------------
0
(1 row)
playboy=> select pg_size_pretty(pg_relation_size('test')); //以KB,MB,GB的方式来查看表大小
pg_size_pretty
----------------
0 bytes
(1 row)
playboy=> select pg_size_pretty(pg_total_relation_size('test')); //查看表的总大小,包括索引大小
pg_size_pretty
----------------
8192 bytes
(1 row)
查看所有所占磁盘空间大小
playboy=> di //相当于mysql的,mysql> show index from test;
List of relations
Schema | Name | Type | Owner | Table
--------+---------------+-------+---------+-------
public | playboy_id_pk | index | playboy | test
(1 row)
playboy=> select pg_size_pretty(pg_relation_size('playboy_id_pk')); //查看索大小
pg_size_pretty
----------------
8192 bytes
(1 row)