oracle dba查询,常用Oracle DBA 查询

—— 肯定有你需要的!

-- -------------------------------------------------------------------

-- Part1 Oracle常用查询

-- -------------------------

--1. 查询系统所有对象

select owner, object_name, object_type, created, last_ddl_time, timestamp, status from

dba_objects

--2. 查看系统所有表

select owner, table_name, tablespace_name from dba_tables

--3. 查看所有用户的表

select owner, table_name, tablespace_name from all_tables

--4. 查看当前用户表

select table_name, tablespace_name from user_tables

--5. 查看用户表索引

select t.*,i.index_type from user_ind_columns t,user_indexes i where

t.index_name = i.index_name and t.table_name = i.table_name

and t.table_name = 要查询的表

--6. 查看主键

select cu.* from user_cons_columns cu, user_constraints au

where cu.constraint_name = au.constraint_name

and au.constraint_type = 'P' and au.table_name = 要查询的表

--7. 查看唯一性约束

select column_name from user_cons_columns cu, user_constraints au

where cu.constraint_name = au.constraint_name and au.constraint_type = 'U'

and au.table_name = 要查询的表

--8. 查看外键

select * from user_constraints c where c.constraint_type = 'R' and c.table_name = 要查询的表

select * from user_cons_columns cl where cl.constraint_name = 外键名称

select * from user_cons_columns cl where cl.constraint_name = 外键引用表的键名

--9. 查看表的列属性

select t.*,c.COMMENTS from user_tab_columns t,user_col_comments c

where t.table_name = c.table_name and t.column_name = c.column_name

and t.table_name = 要查询的表

--10. 查看所有表空间

select tablespace_name from dba_data_files group by tablespace_name

-- -------------------------------------------------------------------

-- Part2 Oracle常用管理

-- -------------------------

--1. 查看Oracle最大连接数

SQL>show parameter processes    #最大连接数

--2. 修改最大连接数

SQL>alter system set processes=value scope=spfile

--重启数据库

SQL>shutdown force

SQL>start force

--3. 查看当前连接数

SQL>select * from V$SESSION where username is not null

--4. 查看不同用户的连接数

SQL>select username,count(username) from V$SESSION where username is not null group by username #查看指定用户的连接数

--5. 查看活动的连接数

SQL>select count(*) from V$SESSION where status='ACTIVE' #查看并发连接数

--6. 查看指定程序的连接数

SQL>select count(*) from V$SESSION where program='JDBC Thin Client' #查看JDBC连接Oracle的数目

--7. 查看数据库安装实例(DBA权限)

SQL>select * from v$instance

--8. 查看运行实例名

SQL>show parameter instance_name

--9. 查看数据库名

SQL>show parameter db_name

--10. 查看数据库域名

SQL>show parameter db_domain

--11. 查看数据库服务名

SQL>show parameter service_names

--12. 查看全局数据库名

SQL>show parameter global

--13. 查看表空间使用率

-- (1)

select dbf.tablespace_name, dbf.totalspace "总量(M)", dbf.totalblocks as "总块数",

dfs.freespace "剩余总量(M)", dfs.freeblocks "剩余块数",

(dfs.freespace / dbf.totalspace) * 100 as "空闲比例"

from (

select t.tablespace_name,

sum(t.bytes) / 1024 / 1024 totalspace,

sum(t.blocks) totalblocks

from dba_data_files t

group by t.tablespace_name) dbf, (

select tt.tablespace_name,

sum(tt.bytes) / 1024 / 1024 freespace,

sum(tt.blocks) freeblocksfrom dba_free_space tt

group by tt.tablespace_name) dfs

where trim(dbf.tablespace_name) = trim(dfs.tablespace_name)

-- (2)

select T.name "Tablespace Name", Free_space, (total_space-Free_space) Used_space, total_space

FROM

(select tablespace_name, sum(bytes/1024/1024) Free_Space

from sys.dba_free_space

group by tablespace_name

) Free,

(select b.name, sum(bytes/1024/1024) total_space

from sys.v_$datafile a, sys.v_$tablespace B

where a.ts# = b.ts#

group by b.name

) T

WHERE Free.Tablespace_name = T.name

-- -------------------------------------------------------------------

作者:yoyudenghihi 发表于2012-7-21 14:05:29 原文链接

阅读:0 评论:0 查看评论

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
真的Oracle 10g的官方速成培训教材 英语原版教材(英文较简单) 主要内容 Chapter 1, "Introduction" This chapter contains an brief overview of Oracle database administration. Chapter 2, "Installing Oracle and Building the Database" This chapter discusses how to install the Oracle software and database. It also describes how to configure additional databases, and how to upgrade and older version of a database to the current version. Chapter 3, "Getting Started with Oracle Enterprise Manager" This chapter introduces you to the Oracle Enterprise Manager and how to use it. Chapter 4, "Configuring the Network Environment" This chapter discusses how to configure a network so that clients can access your databases. Chapter 5, "Managing the Oracle Instance" This chapter discusses starting and stopping the database instance, and managing initialization parameters. Chapter 6, "Managing Database Storage Structures" This chapter discusses management of the database’s storage structure. Chapter 7, "Administering Users and Security" This chapter discusses how to add and maintain user accounts. It includes information about using system privileges and roles to control user access to the database. Chapter 8, "Managing Schema Objects" This chapter discusses managing tables, indexes, and other schema objects. Chapter 9, "Performing Backup and Recovery" This chapter discusses how to backup and recover your database. Chapter 10, "Monitoring and Tuning the Database" This chapter discusses monitoring database activities and diagnosing performance problems.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值