–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

–11. 查看oracle最大连接数
sql>show parameter processes    #最大连接数

–12. 修改最大连接数
sql>alter system set processes=value scope=spfile
–重启数据库
sql>shutdown force
sql>start force

–13. 查看当前连接数
sql>select * from v$session where username is not null

–14. 查看不同用户的连接数
sql>select username,count(username) from v$session where username is not null group by username #查看指定用户的连接数

–15. 查看活动的连接数
sql>select count(*) from v$session where status='active' #查看并发连接数

–16. 查看指定程序的连接数
sql>select count(*) from v$session where program='jdbc thin client' #查看jdbc连接oracle的数目

–17. 查看数据库安装实例(dba权限)
sql>select * from v$instance

–18. 查看运行实例名
sql>show parameter instance_name

–19. 查看数据库名
sql>show parameter db_name

–20. 查看数据库域名
sql>show parameter db_domain

–21. 查看数据库服务名
sql>show parameter service_names

–22. 查看全局数据库名
sql>show parameter global

–23. 查看表空间使用率

 -- ()
select dbf.tablespace_name,
dbf.totalspace "总量(m)",
dbf.totalblocks as "总块数",
dfs.freespace "剩余总量(m)",
dfs.freeblocks "剩余块数",
(dfs.freespace / dbf.totalspace) * as "空闲比例"
from (select t.tablespace_name,
sum(t.bytes) / / totalspace,
sum(t.blocks) totalblocks
from dba_data_files t
group by t.tablespace_name) dbf,
(select tt.tablespace_name,
sum(tt.bytes) / / 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)
-- ()
select t.name "tablespace name",
free_space,
(total_space - free_space) used_space,
total_space
from (select tablespace_name, sum(bytes / / ) free_space
from sys.dba_free_space
group by tablespace_name) free,
(select b.name, sum(bytes / / ) 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

Oracle 常用的查询操作的更多相关文章

  1. Oracle常用SQL查询(2)

    三.查看数据库的SQL 1 .查看表空间的名称及大小 select  t.tablespace_name,  round ( sum (bytes / ( 1024 * 1024 )), 0 ) ts ...

  2. ORACLE 常用SQL查询

    一.ORACLE的启动和关闭 1 .在单机环境下 要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下 su  -  oracle a.启动ORACLE系统 oracle > sv ...

  3. Oracle常用SQL查询

    一.ORACLE的启动和关闭 1.在单机环境下要想启动或关闭oracle系统必须首先切换到oracle用户,如下: su - oracle a.启动Oracle系统 oracle>svrmgrl ...

  4. Oracle常用系统查询SQL

    以user1身份登录oracle,然后执行:select table_name from user_tables;或select table_name from tabs; 常用SQL --1.查询o ...

  5. ORACLE常用系统查询

    目录(?)[-] 查询系统所有对象 查看系统所有表 查看所有用户的表 查看当前用户表 查看用户表索引 查看主键 查看唯一性约束 查看外键 查看表的列属性 查看所有表空间 查看oracle最大连接数 修 ...

  6. Oracle常用数据库表操作

    配置数据库: user:orcl.passward:71911.Hao全局数据库名:orcl..解锁数据库用户名,SCOTT,SYSTEM,SYS,   PWD:71911.Hao输入sqlplus, ...

  7. .NET LINQ基本查询操作

    获取数据源      在 LINQ 查询中,第一步是指定数据源.像在大多数编程语言中一样,在 C# 中,必须先声明变量,才能使用它.在 LINQ 查询中,最先使用 from 子句的目的是引入数据源 ( ...

  8. Oracle手边常用命令及操作语句

    Oracle手边常用命令及操作语句 作者:白宁超 时间:2016年3月4日11:24:08 摘要:日常使用oracle数据库过程中,常用脚本命令莫不是用户和密码.表空间.多表联合.执行语句等常规操作. ...

  9. SQL操作数据——SQL组成,查询基础语法,where,Oracle常用函数等

    SQL组成 DML数据操作语言 DCL数据控制语言 DQL数据查询语言 DDL数据定义语言 查询基础语法 记录筛选 where 子句 记录筛选 where 子句 实例练习 实例练习 Select语句中 ...

随机推荐

  1. 使用FFmpeg如何转发一个RTSP视频流

    版权声明:转载请说明出处:http://www.cnblogs.com/renhui/p/6930221.html   转发RTSP流,这类需求一般出现于转发一些摄像头采集视频,并在摄像头上做RTSP ...

  2. 《机器学习实战(基于scikit-learn和TensorFlow)》第五章内容学习心得

    本章在讲支持向量机(Support Vector Machine). 支持向量机,一个功能强大的机器学习模型,能够执行线性或非线性数据的分类.回归甚至异常值检测的任务.它适用于中小型数据集的分类. 线 ...

  3. MarkDown基础语法记录

    基础语法记录,其中有一些博客园暂不支持 <!--标题--> # 一级标题 # ## 二级标题 ### 三级标题 #### 四级标题 ##### 五级标题 ###### 六级标题 一级标题 ...

  4. 【xsy2305】喽 计算几何

    UPD:这个做法被hack了 题目大意:给你$n$个红点和$m$个黑点,问你至少需要保留多少个黑点,才能用由黑点组成的凸包包住所有红点. 数据范围:$n≤10^5$,$m≤500$ 首先,我们将红点和 ...

  5. 14-02 Java Math类,Random类,System类,BigDecimal类

    Math类 Math的方法 package cn.itcast_01; /* * Math:用于数学运算的类. * 成员变量: * public static final double PI * pu ...

  6. 修改Spring Boot默认的上下文

    前言 默认情况下,Spring Boot使用的服务上下文为"/",我们可以通过"http://localhost:PORT/" 直接诶访问应用: 但是在生产环境 ...

  7. Apache Flume 1.7.0 源码编译 导入Eclipse

    前言 最近看了看Apache Flume,在虚拟机里跑了一下flume + kafka + storm + mysql架构的demo,功能很简单,主要是用flume收集数据源(http上报信息),放入 ...

  8. 一、Windows下Git的安装与配置

    一.下载Git安装包 1.打开Git的官方网站:https://git-scm.com/ 2.找到下载页:https://git-scm.com/downloads 3.找到Windows版本下载页面 ...

  9. 新手易犯的典型缺陷--C#

    这段时间花了点时间整理了几个新手易犯的典型缺陷(专门针对C#的),但是个人的力量毕竟有限缺陷的覆盖面比较窄,有些缺陷的描述也不够准确,这里先贴出来看看能不能集思广益,收集整理出更多的典型缺陷.目标就是 ...

  10. 深入React技术栈之初入React世界

    1.1 react简介 react并不是完整的MVM/MVVM框架,专注于提供清晰.简洁的View层解决方案. 传统开发模式,要更新页面需要手动操作DOM元素.如图1.1所示,React在DOM上封装 ...