在使用达梦数据库或运维时,可能会查看数据库中有哪些表、视图,也可能会查看表空间物理文件的名称和大小,再或者查看数据库的归档方式,这时就可以使用系统表或视图,下面列举一下常用的系统表与视图,然后举几个小例子。
可查询所有对象
可查询表的所有列的信息
可查询表信息(包括系统表)
可查询系统所有用户
可查询数据库文件信息
可查询模式
可查询所有用户的表
可查询当前用户所拥有的所有表
可查询表空间
可查询数据库信息
可查询表空间信息
可查询数据文件信息
可查询归档信息
可查询参数
可查询数据库实例信息
可查询日志文件信息
可查询操作系统CPU和内存的信息
可查询数据库版本
可查询等待(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;
select subtype$ object_type, count(1) quantity from sysobjects where subtype$ <>'' group by subtype$
union
select 'column', count(1) from syscolumns;
文章
阅读量
获赞