ITPub博客

首页 > IT职业 > IT生活 > postgresql怎么查数据库信息

postgresql怎么查数据库信息

IT生活 作者:lizhm 时间:2021-09-11 10:18:43 0 删除 编辑

使用下面的命令查看当前使用的数据库:

select current_database();

postgresql查看数据库大小的方法:

playboy=> l                       //加上字母l,相当于mysql的,mysql> show databases;  
        List of databases  
   Name    |  Owner   | Encoding  
-----------+----------+----------  
 playboy   | postgres | UTF8  
 postgres  | postgres | UTF8  
 template0 | postgres | UTF8  
 template1 | postgres | UTF8  
  
playboy=> select pg_database_size('playboy');    //查看playboy数据库的大小  
 pg_database_size  
------------------  
          3637896  
(1 row)  
  
playboy=> select pg_database.datname, pg_database_size(pg_database.datname) AS size from pg_database;    //查看所有数据库的大小  
  datname  |  size  
-----------+---------  
 postgres  | 3621512  
 playboy   | 3637896  
 template1 | 3563524  
 template0 | 3563524  
(4 rows)  
  
playboy=> select pg_size_pretty(pg_database_size('playboy'));      //以KB,MB,GB的方式来查看数据库大小  
 pg_size_pretty  
----------------  
 3553 kB  
(1 row)

推荐学习:《Python教程》

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4614/viewspace-2833981/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-13

  • 博文量
    78
  • 访问量
    755