oracle的一些操作

--查询sql文的内存使用
SELECT S.MODULE,
       S.*
  FROM v$SQLAREA s
 WHERE s.PARSING_SCHEMA_NAME = 'NEW_CLEAN'
   AND S.MODULE = 'httpd.exe'
   AND sql_text LIKE '%FROM SAISYUBASYO_MST%'

-- 变更默认权ˇ
SELECT * FROM dba_profiles WHERE profile='DEFAULT' AND resource_name='PASSWORD_LIFE_TIME';
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
-- 添加用户
ALTER USER new_clean IDENTIFIED BY new_clean;
用sys登入Oracle DB后,下grant create session to UserName;(UserName是登录出错的用户名)

ALTER USER NEW_CLEAN_CUSTOMIZE IDENTIFIED BY NEW_CLEAN_CUSTOMIZE;
grant create session to NEW_CLEAN_CUSTOMIZE;
grant sysdba to NEW_CLEAN_CUSTOMIZE;

-- 查看oracle占用内存情况
SELECT SUM(VALUE) FROM (SELECT server "リンク型",
       s.username,
       oSUSEr,
       NAME,
       VALUE / 1024 / 1024 VALUE, --"占用内存MB" VALUE,
       s.SID "会话ID",
       s.serial#,
       spid "操作系统进程ID",
       p.PGA_USED_MEM,
       p.PGA_ALLOC_MEM,
       p.PGA_FREEABLE_MEM,
       p.PGA_MAX_MEM
  FROM v$session  s,
       v$sesstat  st,
       v$statname sn,
       v$process  p
 WHERE st.SID = s.SID
   AND st.statistic# = sn.statistic#
   AND sn.NAME LIKE 'session pga memory'
   AND p.addr = s.paddr
  -- AND S.USERNAME='NEW_CLEAN'
 ORDER BY VALUE DESC )


-- 内存使用情况
select name,value/1024/1024 from v$pgastat where name like '%OS';
select name,value from v$pgastat;
select pid,spid,username,pga_used_mem,pga_alloc_mem,pga_freeable_mem,pga_max_mem FROM v$process where pid = 2;
SELECT p.program,
       p.spid,
       p.pid,
       pm.category,
       pm.allocated,
       pm.used,
       pm.max_allocated
  FROM v$process        p,
       v$process_memory pm
 WHERE p.pid = pm.pid
   AND pm.category = 'SQL'
   ORDER BY PM.USED DESC ; --p.pid = 2;
 select name,value,100*( value/decode((select sum(value) from v$sysstat  where name like 'workarea executions%'),0,null,
(select sum(value) from v$sysstat where name like 'workarea executions%'))) pct from v$sysstat where name like 'workarea executions%';


-- 总共的内存ˇ耗
 !ps -ef | grep 172.23.9.99 | head -1
SELECT machine,
       COUNT(*)
  FROM v$session
 GROUP BY machine;
SELECT 'SGA' AS NAME,
       ROUND(SUM(VALUE) / 1024 / 1024, 2) || 'M' AS "SIZE(M)"
  FROM v$sga
UNION
SELECT 'PGA' AS NAME,
       ROUND(VALUE / 1024 / 1024, 2) || 'M' AS "SIZE(M)"
  FROM v$pgastat
 WHERE NAME = 'total PGA allocated'
UNION
SELECT 'TOTAL' AS NAME,
       ((SELECT ROUND(SUM(VALUE) / 1024 / 1024, 2) FROM v$sga) +
       (SELECT ROUND(VALUE / 1024 / 1024, 2) FROM v$pgastat WHERE NAME = 'total PGA allocated')) || 'M' AS "SIZE(M)"
  FROM DUAL
UNION
SELECT NAME,
       TO_CHAR(VALUE)
  FROM V$PGASTAT
 WHERE NAME = 'process count';


2014/03/07
SELECT * FROM All_Objects a WHERE a.OBJECT_TYPE = 'PROCEDURE' AND A.OBJECT_NAME LIKE '%e303%' AND owner = 'NEW_CLEAN_CUSTOMIZE';
SELECT * FROM ALL_SOURCE A WHERE A.type = 'PROCEDURE' AND owner = 'NEW_CLEAN_CUSTOMIZE';
SELECT * FROM USER_PROCEDURES T,DBA_OBJECTS T1 WHERE T.OBJECT_ID=T1.OBJECT_ID AND t1.OBJECT_NAME LIKE '%E303%';


2014/03/11
select 'drop type '||type_name||' force;' from user_types where type_name like '%_DTO%' OR type_name like '%_LIST%' OR type_name like '%_LOGIC%' OR type_name like '%_DAO%';

2014/06/18

UTL_FILE的使用

      1. create directory dir_new_clean_log as 'd:\new_clean\log';
      2. grant read,write on directory dir_new_clean_log to new_clean;
      3. grant execute on utl_file to new_clean;

你可能感兴趣的:(oracle的一些操作)