--oracle监控函数
--查看所有表空间利用率
SELECT?
A.A1?表空间名称,?C.C2?类型,?C.C3?区管理,?
B.B2/1024/1024?表空间大小M,?(B.B2-A.A2)/1024/1024?已使用M,?
SUBSTR((B.B2-A.A2)/B.B2*100,1,5)?利用率
FROM
(SELECT?TABLESPACE_NAME?A1,?SUM(NVL(BYTES,0))?A2?FROM?DBA_FREE_SPACE?GROUP?BY?TABLESPACE_NAME)?A,
(SELECT?TABLESPACE_NAME?B1,SUM(BYTES)?B2?FROM?DBA_DATA_FILES?GROUP?BY?TABLESPACE_NAME)?B,
(SELECT?TABLESPACE_NAME?C1,CONTENTS?C2,EXTENT_MANAGEMENT?C3?FROM?DBA_TABLESPACES)?C
WHERE?A.A1=B.B1?AND?C.C1=B.B1;
--查看所有自建用户
SELECT?USERNAME,DEFAULT_TABLESPACE?FROM?DBA_USERS?WHERE?ACCOUNT_STATUS='OPEN';
--查看所有表空间
SELECT?TABLESPACE_NAME,?SUM(BYTES)/(1024*1024)?AS?MBYTES,?SUM(BLOCKS)?FROM?DBA_SEGMENTS?GROUP?BY?TABLESPACE_NAME;
--查看所有空闲表空间
SELECT?TABLESPACE_NAME,?SUM(BYTES)/(1024*1024)?AS?FREEMBYTES,?SUM(BLOCKS)?FROM?DBA_FREE_SPACE?GROUP?BY?TABLESPACE_NAME;?
--查看所有表空间是否自动扩展
SELECT?FILE_NAME,BYTES/1024/1024?MB,AUTOEXTENSIBLE,TABLESPACE_NAME?FROM?DBA_DATA_FILES;
--查询所有用户及创建时间
SELECT?*?FROM?ALL_USERS;
--查看当前用户连接
SELECT?*?FROM?V$SESSION?WHERE?STATUS='ACTIVE'?AND?SCHEMANAME!='SYS';
--查看当前用户权限
SELECT?*?FROM?SESSION_PRIVS;
--查询当前用户函数和储存过程
SELECT?*?FROM?USER_SOURCE;
--查询当前用户哪个表的记录数最多
SELECT?TABLE_NAME,?TABLESPACE_NAME,?NUM_ROWS,?BLOCKS?FROM?USER_ALL_TABLES?ORDER?BY?NUM_ROWS?DESC;
--查看当前用户哪个表占的空间最大
SELECT?SEGMENT_NAME,TABLESPACE_NAME,BYTES/1024/1024?AS?MBYTES,BLOCKS?FROM?USER_SEGMENTS?WHERE?SEGMENT_TYPE='TABLE'?ORDER?BY?MBYTES?DESC;
--查看坐标投影系
SELECT?*?FROM?SDE.SPATIAL_REFERENCES;
--删除空间索引
DROP?INDEX?TABLENAME_SPATIAL_IDX;
--
SELECT?*?FROM?USER_SDO_GEOM_METADATA
--删除注册空间信息
DELETE?FROM?USER_SDO_GEOM_METADATA?WHERE?TABLE_NAME='TABLENAME';
--删除sde注册空间信息
--echo?y?|?sdelayer?-o?delete?-l?TABLENAME,SPATIALCOLUMN?-u?usr?-p?pwd
DELETE?FROM?SDE.TABLE_REGISTRY?T?WHERE?T.OWNER=='USERNAME'
DELETE?FROM?SDE.COLUMN_REGISTRY?T1?WHERE?T1.OWNER=='USERNAME'
DELETE?FROM?SDE.GEOMETRY_COLUMNS?T2?WHERE?T2.F_TABLE_SCHEMA=='USERNAME'
DELETE?FROM?SDE.GDB_USERMETADATA?T3?WHERE?T3.OWNER=='USERNAME'
DELETE?FROM?SDE.LAYERS?T4?WHERE?T4.OWNER=='USERNAME'
--清空指定名称的表交释放空间
BEGIN?
??FOR?T?IN?(SELECT?TABLE_NAME?FROM?USER_TABLES?WHERE?UPPER(TABLE_NAME)?LIKE?'SMR_%'OR?UPPER(TABLE_NAME)?LIKE?'TMP_%'OR?UPPER(TABLE_NAME)?LIKE?'TEMP_%')?LOOP?
EXECUTE?IMMEDIATE?'TRUNCATE?TABLE?'?||?T.TABLE_NAME;?
??END?LOOP;?
END;?
TRUNCATE?TABLE?SMR_ECABLE_COUNT
commit;
--查看被锁的表
SELECT?P.SPID,?A.SERIAL#,?C.OBJECT_NAME,?B.SESSION_ID,?B.ORACLE_USERNAME,?B.OS_USER_NAME
FROM?V$PROCESS?P,?V$SESSION?A,?V$LOCKED_OBJECT?B,?ALL_OBJECTS?C?
WHERE?P.ADDR=A.PADDR?AND?A.PROCESS=B.PROCESS?AND?C.OBJECT_ID=B.OBJECT_ID??
--查看连接的进程
SELECT?SID,?SERIAL#,?USERNAME,?OSUSER?FROM?V$SESSION;?
--杀掉进程
ALTER?SYSTEM?KILL?SESSION?'SID,SERIAL#';?
操作命令:
SQL>?alter?tablespace?users?offline;
Tablespace?altered.
SQL>?alter?tablespace?users?online;
Tablespace?altered.
将表空间置为只读模式和读写模式:
SQL>?alter?tablespace?users?read?only;
Tablespace?altered.
SQL>?alter?tablespace?users?read?write;
Tablespace?altered.
删除表空间:
SQL>?drop?tablespace?users?including?contents?and?datafiles;
Tablespace?dropped.
create?tablespace?fjng090930?datafile?'d:\oracle\fjng090930.dbf'?size?500m;
alter?database?datafile?'d:\oracle\fjng090930.dbf'?autoextend?on??next?500m?maxsize?unlimited;
create?user?fjng090930?identified?by?fjng090930;?
grant?connect,resource,dba?to?fjng090930;
[email protected]=fj090930?touser=fjng090930?file=d:\fjng090930.dmp
详细解决方案
oracle惯用管理sql
热度:48 发布时间:2016-05-05 12:14:17.0
相关解决方案
- 求教,SSH + ORACLE 日期处理有关问题
- hibernate 连接 oracle session 有关问题
- eclipse+tomcat6.0+oracle 10g配置数据库连接池的异常
- java 生成 word 封存到 oracle 数据库
- oracle 最大连市接数 为什么main方法无限拿连接
- oracle 分页排序,ssi,该怎么处理
- oracle 最近的时间(而不是前一天的时间) 跪求sql语句 。解决方法
- java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:192.168解决思路
- java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver,该怎么处理
- Jsp + Oracle 怎么取回id,报错getInt not implemented for class oracle.jdbc.driver.T4CRo
- oracle 调用java程序,该如何处理
- oracle,该怎么解决
- 在 Hibernate3 查询不到 Oracle 11g 里的记录
- Oracle 评论排序!该怎么解决
- oracle 安装时出现 java tm 异常
- android访问其他数据库(如:oracle、MySql等),希望大家给点建议!解决方案
- oracle sql 有关问题
- oracle 安插 LONG VARCHAR 类型数据
- jdbc+oracle 11中文乱码(英文一般)-在线盼
- ORACLE 一条SQL的有关问题
- oracle loadjava如何用
- netbeans desktop Application 连 Oracle 数据库的有关问题
- Oracle 每天数据备份
- oracle,该如何处理
- C# + SQL server +oracle QQ交流群142703980解决方法
- 求 dotConnect for Oracle 控件破解解决方法
- grove 怎么连 oracle 数据库
- 怎么跟踪winform应用程序发送到数据库的sql(oracle、mssql)
- 小弟我在windows 2008 r2下,使用OleDB方式访问oracle时,提示:未在本地计算机下注册“OraOleDB.Oracle”提供程序
- , 每次玩ASP都会遇到一些恶心的有关问题, 这次是:未能加载文件或程序集“Oracle.DataAccess”或它的某一个依赖项