Oracle 常用SQL

1.查看服务器IP

select UTL_INADDR.get_host_address() from dual;

2.当前会话主机IP

select sys_context('USERENV', 'IP_ADDRESS') from dual

3.服务器主机名

SELECT host_name from v$instance;

4.当前会话主机名

select sys_context('USERENV', 'HOST') from dual;

5.查询服务器平台信息

SELECT * FROM DBA_REGISTRY_DATABASE;

6.查询服务器内存大小

SELECT value / 1024 / 1024 / 1024 G
  FROM v$osstat
 where stat_name = 'PHYSICAL_MEMORY_BYTES'

7.查看控制信息

select name from v$controlfile;

8.查看数据文件

select file_name from dba_data_files;

9.查看日志文件

select member from v$logfile;

10.查看临时文件

select file_name from Dba_temp_files;

11.查看archive log

select name from v$archived_log

12.查询当前用户

show user

13.查询当前用户所有表

select unique tname from col;
--或者
select * from user_tables;
--或者
select * from tab;

14.查看数据库创建时间

SELECT TO_CHAR(CREATED, 'YYYY-MM-DD,HH24:MI:SS'), LOG_MODE FROM V$DATABASE;

15.查看数据对象

select owner, object_type, status, count(*) count#
  from all_objects
 group by owner, object_type, status;

16.查看不同用户的连接数

select username, count(username)
  from v$session
 where username is not null
 group by username;

你可能感兴趣的:(Oracle,oracle,sql,数据库)