PostgreSql9 查看数据库相关信息
2015-06-12 21:37
417 查看
1、检查数据库版本:
2、查看数据库启动时间:
截至当前时间,运行了多长时间:
3、列出当前所有数据库:
或
4、查看数据库文件大小
上面是当前数据库
或者所有数据库文件大小:
postgres=# select version(); version -------------------------------------------------------------------------------- ----------------------------- PostgreSQL 9.4.2 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 5.1.1 201504 22 (Red Hat 5.1.1-1), 64-bit (1 行记录)
2、查看数据库启动时间:
postgres=# select pg_postmaster_start_time(); pg_postmaster_start_time ------------------------------- 2015-06-12 19:06:23.031591+08
截至当前时间,运行了多长时间:
postgres=# select current_timestamp - pg_postmaster_start_time() as uptime; uptime ----------------- 02:34:13.631323
postgres=# select date_trunc('second',current_timestamp-pg_postmaster_start_time()) as uptime; uptime ---------- 02:36:10
3、列出当前所有数据库:
bash-4.3$ psql -l 资料库列表 名称 | 拥有者 | 字元编码 | 校对规则 | Ctype | 存取权限 -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | template0 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (3 行记录)
或
ostgres=# select datname from pg_database; datname ----------- template1 template0 postgres (3 行记录)
4、查看数据库文件大小
postgres=# select pg_database_size(current_database()); pg_database_size ------------------ 6999828
上面是当前数据库
postgres=# select current_database(); current_database ------------------ postgres
或者所有数据库文件大小:
postgres=# select sum(pg_database_size(datname)) from pg_database; sum ---------- 20738844 (1 行记录)
相关文章推荐
- Ubuntu 安装mysql和简单操作
- 对数据库中的元素增加约束
- oracle建立了监听为什么在服务中没有显示?
- Mysql 数据库中文乱码问题
- 简单Servlet
- 向数据库中增删改查数据
- 数据库中等值连接与自然连接的区别
- Winform开发框架中实现同时兼容多种数据库类型处理
- 基于Enterprise Library的Winform开发框架实现支持国产达梦数据库的扩展操作
- 国产达梦数据库的结合Enterprise Library的应用开发
- mysql免安装版配置
- linux下如何安装配置redis及主从配置
- 【小技巧】SQLite语句设置 自动增长字段
- Oracle同义词
- oracle 10g数据类型整理
- MongoDB 2.6 兼容性改变 -- db.collection.aggregate()改变
- 数据库的级联删除
- scrapy爬虫成长日记之将抓取内容写入mysql数据库
- SQL SERVER索引
- 数据库基线