• 技术文章 >数据库 >PostgreSQL

    postgresql怎么查数据库信息

    yangyang2020-04-05 11:56:18原创4353

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

    1

    select current_database();

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

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    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教程

    专题推荐:postgresql
    上一篇:postgresql怎么关闭服务器 下一篇:postgresql如何计算两日期间有多少天

    相关文章推荐

    • PostgreSQL停止不了怎么办• postgresql怎么建库• postgresql怎么关闭服务器

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网