–1. 查询系统全部对象

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

from dba_objects

where owner=upper('scott')

–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 = upper('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 =  upper('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

############################################

–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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--
(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)
freeblocks
          from 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

IT忍者神龟之Oracle DBA经常使用查询吐血列举的更多相关文章

  1. IT忍者神龟之 oracle行转列、列转行

    一.行转列 须要将例如以下格式 转换为: 这就是最常见的行转列,主要原理是利用decode函数.聚集函数(sum).结合group by分组实现的 create table test( id varc ...

  2. IT该忍者神龟Oracle 树操作(select…start with…connect by…prior)

    oracle树查询的最重要的就是select-start with-connect by-prior语法了.依托于该语法.我们能够将一个表形结构的以树的顺序列出来. 在以下列述了oracle中树型查询 ...

  3. Oracle DBA常用查询

    Oracle DBA常用查询 –1. 查询系统所有对象select owner, object_name, object_type, created, last_ddl_time, timestamp ...

  4. Oracle DBA的神器: PRM恢复工具,可脱离Oracle软件运行,直接读取Oracle数据文件中的数据

    Oracle DBA的神器: PRM恢复工具,可脱离Oracle软件运行,直接读取Oracle数据文件中的数据 PRM 全称为ParnassusData Recovery Manager ,由 诗檀软 ...

  5. oracle DBA坚持写博客的7大理由

    对于Oracle DBA来说,甚至IT技术人员来说.坚持写博客是个好习惯.以下是我建议大家写博客的七个理由. 帮助整理思路 最近我做出了一个决定,那就是: 我要坚持天天写博客,记录每天所学的重要东西. ...

  6. oracle dba 职责, 及个人需要掌握内容

    ORACLE DBA 职责, 基本相当于日常工作. 0. 数据库设计 1. 模式对象的创建与管理(table, index 等等) 2. 事物管理, 例如并发等 3. SQL 调优 只是针对SQL的 ...

  7. Oracle DBA 的常用Unix参考手册(二)

    9.AIX下显示CPU数量    # lsdev -C|grep Process|wc -l10.Solaris下显示CPU数量# psrinfo -v|grep "Status of pr ...

  8. Oracle DBA 的常用Unix参考手册(一)

    作为一名Oracle DBA,在所难免要接触Unix,但是Unix本身又是极其复杂的,想要深刻掌握同样很不容易.那么到底我们该怎么入手呢?Donald K Burleson 的<Unix for ...

  9. (摘)ORACLE DBA的职责

    ORACLE数据库管理员应按如下方式对ORACLE数据库系统做定期监控: (1). 每天对ORACLE数据库的运行状态,日志文件,备份情况,数据 库的空间使用情况,系统资源的使用情况进行检查,发现并解 ...

随机推荐

  1. javascript 学习随笔7

    <head> <title>标题页-学无忧(www.xue51.com)</title> <script language="JavaScript& ...

  2. Nginx阅读笔记(三)之proxy_pass用法

    在nginx中配置proxy_pass时,当在后面的url加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走,如果没有/,则会把匹配的路径部分也给代理走. 假设访问 ...

  3. MVC3 Html.ActionLink

    以下使用参数文字说明: linkText:生成的链接所显示的文字   类型:string actionName:对应控制器的方法 类型:string routeValues:向对应的action传递的 ...

  4. Poj 2499 Binary Tree(贪心)

    题目链接:http://poj.org/problem?id=2499 思路分析:结点向左边移动时结点(a, b)变为( a+b, b),向右边移动时( a, b )变为( a, a + b); 为求 ...

  5. uva11178 Morley’s Theorem(求三角形的角三分线围成三角形的点)

    Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states that that the ...

  6. HDU1163【九余数定理】【水题】

    Eddy's digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  7. stm32之Systick(系统时钟)

    Systick的两大作用: 1.可以产生精确延时: 2.可以提供给操作系统一个单独的心跳(时钟)节拍: 通常实现Delay(N)函数的方法为: for(i=0;i<x;i++) ; 对于STM3 ...

  8. ubuntu15.04安装hexo

    首先吐槽一下npm淘宝源,貌似中国目前唯一一个npm源,现在不好用了,不知道是不是换了地址,在吐槽一下万恶的墙!你懂得. 好了,说点正儿八经的事儿. 之所以安装hexo也是为了创建自己的博客,我只说最 ...

  9. listview添加onItemClickListener

    MainActivity.java package com.wyl.listview04; import java.util.ArrayList; import java.util.HashMap; ...

  10. input file 在开发中遇到的问题 类似ajax form表单提交 input file中的文件

    最近在做项目的过程中遇到个问题,在这里做个记录防止日后忘记 现今的主流浏览器由于ajax提交form表单无法把文件类型数据提交到后台,供后台处理,可是开发中由于某些原因又不得不用ajax提交文件, 为 ...