注册
达梦常用的系统表和视图
培训园地/ 文章详情 /

达梦常用的系统表和视图

9527XX 2022/12/13 7768 1 0

达梦数据库常用的系统表和视图

在使用达梦数据库或运维时,可能会查看数据库中有哪些表、视图,也可能会查看表空间物理文件的名称和大小,再或者查看数据库的归档方式,这时就可以使用系统表或视图,下面列举一下常用的系统表与视图,然后举几个小例子。

系统表

SYSOBJECTS

可查询所有对象

SYSCOLUMNS

可查询表的所有列的信息

dba_tables

可查询表信息(包括系统表)

dba_users

可查询系统所有用户

dba_data_files

可查询数据库文件信息

dba_segments

可查询模式

all_tables

可查询所有用户的表

user_tables

可查询当前用户所拥有的所有表

user_tablespaces

可查询表空间

系统视图

v$database

可查询数据库信息

v$tablespace

可查询表空间信息

v$datafile

可查询数据文件信息

v$dm_arch_ini

可查询归档信息

v$dm_ini

可查询参数

v$instance

可查询数据库实例信息

v$rlogfile

可查询日志文件信息

v$systeminfo

可查询操作系统CPU和内存的信息

v$version

可查询数据库版本

v$wait_class

可查询等待(wait)情况

相关例子

查看表空间的名称和大小
select name, total_size * sf_get_page_size() / 1024 / 1024 || 'M' from v$tablespace;
查看表空间物理文件的名称和大小
select t.name tablespace_name, t.id file_id, d.path file_name, d.total_size * sf_get_page_size() / 1024 / 1024 || 'M' total_space from v$tablespace t, v$datafile d where t.id = d.group_id;
查看表空间使用情况
select t1.NAME tablespace_name, t2.FREE_SIZE * SF_GET_PAGE_SIZE() / 1024 / 1024 || 'M' free_space, t2.TOTAL_SIZE * SF_GET_PAGE_SIZE() / 1024 / 1024 || 'M' total_space, t2.FREE_SIZE * 100 / t2.total_size" % FREE" from V$TABLESPACE t1, V$DATAFILE t2 where t1.ID = t2.GROUP_ID;
查看控制文件
select para_value name from v$dm_ini where para_name='CTL_PATH';
查看日志文件大小
select PATH, RLOG_SIZE / 1024 / 1024 || 'M' from v$rlogfile;
查看数据库对象
select t2.name owner, t1.subtype$ object_type, t1.valid status, count(1) count# from sysobjects t1, sysobjects t2 where t1.schid = t2.id and t1.schid != 0 group by t2.name, t1.subtype$, t1.valid;
查看数据库创建日期和归档方式
select create_time, case when arch_mode = 'n' then '非归档模式' else '归档模式' end arch from v$database;
查看object分类数量
select subtype$ object_type, count(1) quantity from sysobjects where subtype$ <>'' group by subtype$ union select 'column', count(1) from syscolumns;
评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服