-- 查询授权信息
select from v$license;
-- 查询用户相关的表信息
select table_name from dba_tables where owner='DMHR';
-- 查看表空间的名称和大小
select name,total_sizesf_get_page_size()/1024/1024 || 'M' from v$tablespace;
-- 查看表空间物理文件的名称和大小
select t.name tablespace_name,t.id file_id,d.path file_name,d.total_sizesf_get_page_size()/1024/1024||'m' total_space from v$tablespace t, v$datafile d where t.id=d.group_id;
-- 查看日志文件
select PATH,RLOG_SIZE/1024/1024||'M' from v$rlogfile;
-- 查看表空间使用情况
select t1.NAME tablespace_name, t2.FREE_SIZESF_GET_PAGE_SIZE()/1024/1024 ||'M' free_space, t2.TOTAL_SIZESF_GET_PAGE_SIZE()/1024/1024 ||'M' total_space, t2.FREE_SIZE100/t2.total_size "% FREE" from V$TABLESPACE t1, V$DATAFILE t2 where t1.ID=t2.GROUP_ID;
sql> select * from v$version; //查看版本
SQL> select id_code; //查看具体版本号
sql> select name inst_name from v$instance; //查看实例名
sql> select status$ from v$instance; //查看数据库状态
sql> select db_magic from v$rlog; //查询DB_MAGIC
sql> select arch_mode from v$database; //查询是否归档模式
sql> select EXPIRED_DATE from v$license; //查询授权有限期
sql> select class_name,total_waits count from v$wait_class; //查询等待情况
SQL> select para_name,para_value from v$dm_ini where para_name like '%PORT%'; //查询数据库配置端口
SQL> select SF_GET_PARA_VALUE(2,'MAX_SESSIONS'); //查询最大连接数
SQL> select count(*) from v$sessions where state='ACTIVE'; //活动会话数量
//关不掉的时候 用这个
call SP_CANCEL_SESSION_OPERATION(sess_id);
SQL> select a.tablespace_name,a.bytes/1024/1024 "Sum MB",(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024 "free MB",round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"
from (select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,
(select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name
order by ((a.bytes-b.bytes)/a.bytes) desc; //查询表空间使用情况
SQL> select SYS_CONTEXT ('userenv','current_schema') from dual; //当前用户
SQL> select username from dba_users; //查询库有哪些用户
SQL> select username,user_id,default_tablespace,profile from dba_users; //查询用户信息
SQL> select count(*) from dba_tables; //查询总表数量
SQL> select table_name,tablespace_name from user_tables; //查询当前用户所有表
//查询数据库的cpu
select * from v$sysstat where name like '%cpu%';
//查询数据库的最大连接数
select SF_GET_PARA_VALUE(2,'MAX_SESSIONS');
达梦视图查系统索引
select index_name,column_name,column_position from dba_ind_columns where table_name='TAB' order by 1,3
-- 获取达梦数据库关键字
询V$RESERVED_WORDS视图,select * from V$RESERVED_WORDS
-- 查询系统版本的命令,来查看数据库版本命令
dmdbms/bin目录下执行
./disql -id
-- 查询数据库的模式
SELECT "NAME" "实例名称" , "MODE$" "数据库模式" FROM V$INSTANCE;
文章
阅读量
获赞