Oracle日常维护脚本
1.正常停库流程
ps -ef|grep LOCAL=NO|cut -c 9-15|xargs kill -9
shutdown immediate;
2.备份数据库
backup database format '/home/orarch_ccmpdb1/backup2/full_%d_%s_%p_%u.%T';
backup current controlfile format '/home/orarch_ccmpdb1/backup2/controlfile_%d_%s_%p_%u.%T';
3.建立连接
ln -s /dev/ccmpvg01/rccmpv01l3111 /home/db/oracle/oradata/cmpdb/rtbs_data2_05_10g
ln -s /dev/ccmpvg01/rccmpv01l3112 /home/db/oracle/oradata/cmpdb/rtbs_data2_06_10g
4.增加表空间的空间
alter tablespace tbs_data2 add datafile
'/home/db/oracle/oradata/cmpdb/rtbs_data2_05_10g' size 10200m,
'/home/db/oracle/oradata/cmpdb/rtbs_data2_06_10g' size 10200m;
5.查看主分区表和子分区表
col partition_keyname for a20
col sub_partition_keyname for a20
select a.*,b.COLUMN_NAME sub_partition_keyname from
(select t1.OWNER,
t1.TABLE_NAME,
t1.PARTITIONING_TYPE,
t1.SUBPARTITIONING_TYPE,
t1.PARTITION_COUNT,
t2.column_name partition_keyname
from dba_part_tables t1,dba_part_key_columns t2
where t1.owner = t2.owner
and t1.table_name = t2.name
and t1.OWNER = 'BILL'
and t1.TABLE_NAME = 'HA_CREDIT_CTRL'
) a,dba_subpart_key_columns b
where a.owner = b.owner(+)
and a.table_name = b.name(+);
6.查看子分区信息
select TABLE_OWNER,
TABLE_NAME,
PARTITION_NAME,
SUBPARTITION_NAME,
SUBPARTITION_POSITION
from DBA_TAB_SUBPARTITIONS
where TABLE_OWNER = 'CASHBILL_TEST'
and TABLE_NAME = 'BALANCE_PAYOUT'
order by PARTITION_NAME,SUBPARTITION_POSITION;
select dbms_metadata.get_ddl('TABLE','ACCT_ITEM_1080','CASH_BILL') from dual;
7.段级别统计信息
select owner,object_name,statistic_name,value
from v$segment_statistics
where owner='SYS' and object_name = 'I_FILE2'
8.看最严重的前20个等待事件
set lines 200
set pages 200
col sql_text for a70
col name for a30
col parameter1 for a30
col parameter2 for a30
col parameter3 for a30
col value for 999999999999999999
col gets for 9999999999999999999
col wait_time for 9999999999999999
select * from (select event,wait_time,SECONDS_IN_WAIT from v$session_wait
where wait_class not in ('Idle','Network') order by SECONDS_IN_WAIT desc)
where rownum <= 20;
9.看最严重的等待事件
select event,count(*) from v$session
where wait_class not in ('Idle','Network')
group by event
order by 2 desc;
10.看当前连接会话信息
select username,program,status,count(*) from v$session
where username is not null group by username,program,status order by 3;
select prev_sql_id,count(*) from v$session
where program is null group by prev_sql_id order by 2
11.最严重的前10个latch
select * from (select addr,name,gets,misses,sleeps,SPIN_GETS,WAIT_TIME
from v$latch order by misses desc) where rownum <= 10
--latch: row cache objects
select distinct s.kqrstcln latch#,
r.cache#,
r.parameter name,
r.type,
r.subordinate#,
r.gets
from v$rowcache r,x$kqrst s
where r.cache# = s.kqrstcid
order by 1,4,5;
select * from (select cache#,type,SUBORDINATE#,parameter,count,
USAGE,GETS,GETMISSES from v$rowcache order by GETMISSES desc)
where rownum <= 10;
select addr,latch#,child#,level#,name,gets from v$latch_children
where name = 'row cache objects' and gets <>0 order by gets;
--latch cbc
--个个查询
select * from (select addr from v$latch_children
where name = 'cache buffers chains' order by misses)
where rownum <= 10;
select /*+ rule */ owner,object_name from dba_objects
where object_id in
(select /*+ rule */ distinct obj from x$bh
where hladdr = 'C000000BC6813AB8');
12.查询前十个cbc latch最严重对应的对象
select /*+ rule */ owner,object_name from dba_objects where object_id in
(
select /*+ rule */ distinct obj from x$bh where hladdr in
(select /*+ rule */ * from (select /*+ rule */ addr
from v$latch_children
where name = 'cache buffers chains'
order by gets desc) where rownum <= 10)
);
13.检查分区表的创建与否
select TABLE_OWNER,
TABLE_NAME,
PARTITION_NAME,
SUBPARTITION_NAME,
SUBPARTITION_POSITION
from DBA_TAB_SUBPARTITIONS
where TABLE_OWNER = 'CASHBILL_TEST'
and TABLE_NAME = 'BALANCE_PAYOUT'
order by PARTITION_NAME,SUBPARTITION_POSITION;
14.表空间自动扩展性
SELECT T.TABLESPACE_NAME,D.FILE_NAME,D.AUTOEXTENSIBLE,D.BYTES,D.MAXBYTES,D.STATUS
FROM DBA_TABLESPACES T,DBA_DATA_FILES D
WHERE T. TABLESPACE_NAME =D. TABLESPACE_NAME
ORDER BY TABLESPACE_NAME,FILE_NAME;
15.全表扫描 ,注意修改 OBJECT_OWNER
select distinct t.sql_text from v$sqlarea t, v$sql_plan p
where t.hash_value=p.hash_value
and t.SQL_ID=p.SQL_ID
and t.PLAN_HASH_VALUE=p.PLAN_HASH_VALUE
and p.operation='TABLE ACCESS'
and p.options='FULL'
and p.OBJECT_OWNER ='TBMS';
16.全索引扫描, 注意修改 OBJECT_OWNER
select distinct t.sql_text from v$sqlarea t, v$sql_plan p
where t.hash_value=p.hash_value
and t.SQL_ID=p.SQL_ID
and t.PLAN_HASH_VALUE=p.PLAN_HASH_VALUE
and p.operation='INDEX'
and p.options='FULL SCAN'
and p.OBJECT_OWNER ='TBMS';
17.查看归档错误:
select dest_id,error from v$archive_dest where dest_id=1;
18.数据字典命中率
column parameter format a21
column pct_succ_gets format 999.9
column updates format 999,999,999
SELECT parameter
, sum(gets)
, sum(getmisses)
, 100*sum(gets - getmisses) / sum(gets) pct_succ_gets
, sum(modifications) updates
FROM V$ROWCACHE WHERE gets > 0
GROUP BY parameter;
19.查看归档错误
select dest_id,error from v$archive_dest where dest_id=1;
20.是否有行迁移
--收集对象的统计信息:
analyze table t compute statistics;
select TABLE_NAME,BLOCKS,EMPTY_BLOCKS,NUM_ROWS,AVG_ROW_LEN,CHAIN_CNT
from user_tables where table_name='T';
21.取出全表扫描的表
select sql_text from v$sqltext where sql_id in
(select sql_id from v$sql_plan
where operation like '%TABLE ACCESS%'
and options like '%FULL%')
where sql_text like '%EMP%'
22.全表扫描统计项
select name,value from v$sysstat where name like 'table scan%';
23.哪个用户哪个表作了全表扫描
select OPERATION,object_owner,OPTIONS,OBJECT_NAME from
v$sql_plan
where options='FULL'
and OPERATION='TABLE ACCESS'
and object_owner='SCOTT';
24.哪个用户下有多少张表作了全表扫描
select ss.username||'('||se.sid||') ' "User Process",
sum(decode(name,'table scans (short tables)',value)) "Short Scans",
sum(decode(name,'table scans (long tables)', value)) "Long Scans",
sum(decode(name,'table scan rows gotten',value)) "Rows Retreived"
from v$session ss,
v$sesstat se,
v$statname sn
where se.statistic# = sn.statistic#
and (name like '%table scans (short tables)%'
or name like '%table scans (long tables)%'
or name like '%table scan rows gotten%')
and se.sid = ss.sid
and ss.username is not null
group by ss.username||'('||se.sid||') '
/
25.增加全表扫描时I/O的吞吐量
db_file_multiblock_read_count=1~128
26.使用并行处理提高全表扫描效率:
select /*+ parallel (ob ,16)*/ count(*) from OB;
27.条带化堆表数据:
alter table ob allocate extent (size 5m datafile '/u01/app/oracle/oradata/madrid/users01.dbf');
alter table ob allocate extent (size 5m datafile '/u01/app/oracle/oradata/madrid/users02.dbf');
alter table ob allocate extent (size 5m datafile '/u01/app/oracle/oradata/madrid/users03.dbf');
alter table ob allocate extent (size 5m datafile '/u01/app/oracle/oradata/madrid/users04.dbf');
28.发生cbc latch争用时,如可查是哪个sql语句造成的 ?
select v.SQL_HASH_VALUE, v.SQL_ADDRESS, v.INST_ID, v.EVENT
from gv$session v
where v.EVENT = 'cache buffer chains';
select a.INST_ID, a.SQL_TEXT from gv$sqltext a
where a.HASH_VALUE = '&HASH_VALUE'
and a.ADDRESS = '&ADDRESS'
ORDER BY address, hash_value, piece;
29.数据字典命中率
column parameter format a21
column pct_succ_gets format 999.9
column updates format 999,999,999
SELECT parameter
, sum(gets)
, sum(getmisses)
, 100*sum(gets - getmisses) / sum(gets) pct_succ_gets
, sum(modifications) updates
FROM V$ROWCACHE WHERE gets > 0
GROUP BY parameter;
30.估算 db_cache 放大或减小后对 I/o 的影响
COLUMN size_for_estimate FORMAT 999,999,999,999 heading 'Cache Size (MB)'
COLUMN buffers_for_estimate FORMAT 999,999,999 heading 'Buffers'
COLUMN estd_physical_read_factor FORMAT 999.90 heading 'Estd Phys|Read Factor'
COLUMN estd_physical_reads FORMAT 999,999,999 heading 'Estd Phys| Reads'
SELECT size_for_estimate, buffers_for_estimate, estd_physical_read_factor,
estd_physical_reads
FROM V$DB_CACHE_ADVICE
WHERE name = 'DEFAULT'
AND block_size = (SELECT value FROM V$PARAMETER WHERE name = 'db_block_size')
AND advice_status = 'ON';
31.查看 db_buffer 的命中率
SELECT NAME, PHYSICAL_READS, DB_BLOCK_GETS, CONSISTENT_GETS,
1 - (PHYSICAL_READS / (DB_BLOCK_GETS + CONSISTENT_GETS)) "Hit Ratio"
FROM V$BUFFER_POOL_STATISTICS;
32.查询收集统计信息作业,什么时候开始的,什么时候结束的
select
STATE,
ENABLED,
RUN_COUNT,
to_char(END_DATE,'yyyy-mm-dd hh24:mi:ss'),
to_char(LAST_START_DATE,'yyyy-mm-dd hh24:mi:ss'),
LAST_RUN_DURATION,
to_char(NEXT_RUN_DATE,'yyyy-mm-dd hh24:mi:ss')
from DBA_SCHEDULER_JOBS where JOB_NAME='GATHER_STATS_JOB';
33.收集统计信息
exec dbms_stats.gather_table_stats(
ownname=>'用户名',
tabname=>'表名',
degree =>DBMS_STATS.DEFAULT_DEGREE,
cascade=>true,
estimate_percent=>100,
method_opt=>'FOR ALL INDEXED COLUMNS SIZE AUTO',
no_invalidate=>false);
exec dbms_stats.gather_table_stats
( ownname=>'ULTRANMS',tabname=>'PM_RAW_RESSWAP',cascade=>true,DEGREE=>2);
34.查找数据库中僵死进程
select pid, spid, username, terminal, program
from v$process
where addr not in (select paddr from v$session);
alter system kill session 'sid,serial#' ;
select saddr,sid,serial#,paddr,username,status
from v$session where username is not null;
35.捕获占用CPU利用率过高的SQL语句:
set line 240
set verify off
column sid format 999
column pid format 999
column S_# format 999
column username format A9 heading "ORA User"
column program format a29
column SQL format a60
COLUMN OSname format a9 Heading "OS User"
SELECT P.pid pid,S.sid sid,P.spid spid,S.username username,
S.osuser osname,P.serial# S_#,P.terminal,P.program program,
P.background,S.status,RTRIM(SUBSTR(a.sql_text, 1, 80)) SQL
FROM v$process P, v$session S,v$sqlarea A WHERE P.addr = s.paddr
AND S.sql_address = a.address (+) AND P.spid LIKE '%&1%';
--查看运行时间很长的sql
select username,sid,opname,
round(sofar*100 / totalwork,0) || '%' as progress,
time_remaining,sql_text
from v$session_longops , v$sql
where time_remaining <> 0
and sql_address = address
and sql_hash_value = hash_value
36.如何知道使用CPU多的用户session?
select a.sid,spid,status,substr(a.program,1,40) prog,
a.terminal,osuser,value/60/100 value
from v$session a,v$process b,v$sesstat c
where c.statistic#='cpu used by this session' and
c.sid=a.sid and a.paddr=b.addr order by value desc;
37.占CPU资源多的SESSION
select s.sid,s.value "CPU Used"
from v$sesstat s,v$statname n
where s.statistic#=n.statistic# and n.name='CPU used by this session'
and s.value>0
order by 2 desc;
38.查等待事件
set linesize 125
select sid,event from v$session_wait
where event not like 'SQL*N%' and
event not like 'rdbms%' and
event not like 'single%';
39.手工查询等待事件:
select sid,event ,p1,p2,p3 from v$session_wait
where event not like 'rdbms%' and event not like 'SQL%';
40.查询做比较大的排序的进程?
SELECT b.tablespace, b.segfile#, b.segblk#, b.blocks, a.sid, a.serial#,
a.username, a.osuser, a.status
FROM v$session a,v$sort_usage b
WHERE a.saddr = b.session_addr
ORDER BY b.tablespace, b.segfile#, b.segblk#, b.blocks ;
41.查询做比较大的排序的进程的SQL语句?
select /*+ ORDERED */ sql_text from v$sqltext a
where a.hash_value = (
select sql_hash_value from v$session b
where b.sid = &sid and b.serial# = &serial)
order by piece asc ;
42.磁盘IO:
col name for a50
select name,phyrds,phywrts,readtim,writetim
from v$filestat a,v$dbfile b
where a.file# = b.file#
order by readtim desc;
43.查询在线重做日志文件切换频率:
select b.recid,
to_char(b.first_time,'dd-mon-yy hh:mi:ss') start_time,
a.recid,
to_char(a.first_time,'dd-mon-yy hh:mi:ss') end_time,
round(((a.first_time - b.first_time)*24)*60,2) minutes
from v$log_history a,v$log_history b
where a.recid = b.recid+1
order by a.first_time asc;
/
44.查看回滚段信息
Select Segment_Name,
Tablespace_Name,
R.Status,
(Initial_Extent / 1024) Initialextent,
(Next_Extent / 1024) Nextextent,
Max_Extents,
V.Curext Curextent
From Dba_Rollback_Segs r, V$rollstat v
Where R.Segment_Id = V.Usn(+)
Order By Segment_Name;
45.如何察看回滚段竞争情况
Select * from v$undostat;
返回结果中nospaceerrcnt字段的值应该为0,如果持续出现非0,建议增加回滚段表空间大小.
46.如何获取错误信息
SELECT * FROM USER_ERRORS;
47.34.内核参数的作用
shmmax含义:这个设置并不决定究竟Oracle数据库或者操作系统使用多少物理内存,只决定了最多可以使用的内存数目。这个设置也不影响操作系统的内核资源。设置方法:0.5*物理内存例子:Set shmsys:shminfo_shmmax=10485760
shmmin 含义:共享内存的最小大小。设置方法:一般都设置成为1。例子:Set shmsys:shminfo_shmmin=1:
shmmni 含义:系统中共享内存段的最大个数。例子:Set shmsys:shminfo_shmmni=100
shmseg 含义:每个用户进程可以使用的最多的共享内存段的数目。例子:Set shmsys:shminfo_shmseg=20:
semmni 含义:系统中semaphore identifierer的最大个数。设置方法:把这个变量的值设置为这个系统上的所有Oracle的实例的init.ora中的最大的那个processes的那个值加10。例子:Set semsys:seminfo_semmni=100
semmns 含义:系统中emaphores的最大个数。设置方法:这个值可以通过以下方式计算得到:各个Oracle实例的initSID.ora里边的processes的值的总和(除去最大的Processes参数)+最大的那个Processes×2+10×Oracle实例的个数。例子:Set semsys:seminfo_semmns=200
semmsl: 含义:一个set中semaphore的最大个数。设置方法:设置成为10+所有Oracle实例的InitSID.ora中最大的Processes的值。例子:Set semsys:seminfo_semmsl=-200
48.修改sqlnet.ora,实现客户端IP限制
如果要在网络上做一些IP地址的限制,一般情况下我们首先想到的是用网络层的防火墙软件。要找网管来设置。 但是如果网管不在,或者仅仅想在数据库层来实现IP地址的限制,DBA们只要修改Server端的一个网络配置文件
sqlnet.ora文件就可以了。
Oracle9i以上版本,在目录$ORACLE_HOME/network/admin 或者 %ORACLE_HOME%/network/admin 下)增加如下内容:
tcp.validnode_checking=yes
tcp.invited_nodes =(ip1,ip2,……) #允许访问的ip
tcp.excluded_nodes=(ip1,ip2,……) #不允许访问的ip
修改sqlnet.ora后,重新启动listener服务,改动就可以生效了。
1.分析表
analyze table mzbs.db_code ESTIMATE STATISTICS SAMPLE 20 PERCENT;
--推荐使用dbms_stats包来收集统计信息
2.表空间管理和用户管理
--强行离线表空间(offline tablespace)
alter tablespace users offline immediate;
--查看表空间和数据文件
select file_name,tablespace_name,autoextensible from dba_data_files;
--数据表空间
CREATE TABLESPACE USER_DATA LOGGING
DATAFILE
'D:/ORACLE/ORADATA/ORCL/test.DBF' SIZE 50m REUSE ,
'c:/USERS01112.DBF' SIZE 50m REUSE
AUTOEXTEND ON NEXT 1280K MAXSIZE 16383M EXTENT MANAGEMENT LOCAL
--修改表空间数据文件的路径
ALTER TABLESPACE app_data RENAME DATAFILE '/DISK4/app_data_01.dbf' TO '/DISK5/app_data_01.dbf';
ALTER DATABASE RENAME FILE '/DISK1/system_01.dbf' TO '/DISK2/system_01.dbf';
--临时表空间
CREATE TEMPORARY TABLESPACE USER_DATA_TEMP
TEMPFILE 'D:/TEMP0111.DBF' SIZE 50M REUSE AUTOEXTEND ON NEXT 1024K MAXSIZE 16383M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1024K
--增加数据文件
ALTER TABLESPACE USER_DATA ADD DATAFILE 'c:/USERS01113.DBF' SIZE 50M;
ALTER TABLESPACE USER_DATA ADD DATAFILE 'c:/USERS01114.DBF' SIZE 50M AUTOEXTEND ON;
--删除表空间
DROP TABLESPACE USER_DATA INCLUDING CONTENTS;
--修改表空间的存储参数
ALTER TABLESPACE tablespacename MINIMUM EXTENT 2M;
ALTER TABLESPACE tablespacename DEFAULT STORAGE (INITIAL 2M NEXT 2M MAXEXTENTS 999 );
--表空间联机/脱机/只读
ALTER TABLESPACE tablespacename OFFLINE/ONLINE/READ ONLY;
--修改数据文件大小
ALTER DATABASE DATAFILE 'c:/USERS01113.DBF' RESIZE 40M;
--创建用户、赋予权限
CREATE USER USER_DATA PROFILE DEFAULT IDENTIFIED BY USER_DATA
DEFAULT TABLESPACE USER_DATA
TEMPORARY TABLESPACE USER_DATA ACCOUNT UNLOCK;
GRANT CONNECT TO USER_DATA;GRANT RESOURCE TO USER_DATA;
3.表的管理
--创建表
CREAE TABLE TABLENAME
(COLUMN1 COLUTYPE DEFAULT(VALUE) NOT NULL)
(COLUMN2 COLUTYPE DEFAULT(VALUE) NOT NULL);
--建表的索引存储分配
CREATE TABLE summit.employee(
id NUMBER(7) CONSTRAINT employee_id_pk
PRIMARY KEY DEFERRABLE USING INDEX STORAGE(INITIAL 100K NEXT 100K) TABLESPACE indx,
last_name VARCHAR2(25) CONSTRAINT employee_last_name_nn NOT NULL,
dept_id NUMBER(7))TABLESPACE data;
--修改表的存储分配
ALTER TABLE tablenamePCTFREE 30PCTUSED 50STORAGE(NEXT 500KMINEXTENTS 2MAXEXTENTS 100);
ALTER TABLE tablenameALLOCATE EXTENT(SIZE 500KDATAFILE '/DISK3/DATA01.DBF');
--把表移到另一个表空间
ALTER TABLE TABLENAME MOVE TABLESPACE TABLESPACENAME;
--回收空闲的空间(回收到High-water mark)
全部回收需要TRUNCATE TABLE tablename
ALTER TABLE tablenameDEALLOCATE UNUSED;
--删除表(连同所用constraint)
DROP TABLE tablenameCASCADE CONSTRAINTS;
--给表增加列
ALTER TABLE TABLENAMEADD COLUMN COLUTYPE DEFAULT(VALUE) NOT NULL;
--删除表中的列
ALTER TABLE tablenameDROP COLUMN columnname;
ALTER TABLE tablenameDROP COLUMN columnnameCASCADE CONSTRAINTS CHECKPOINT 1000;
--标记列不可用
ALTER TABLE tablenameSET UNUSED COLUMN columnnameCASCADE CONSTRAINTS;
--删除标记为不可用的列
ALTER TABLE tablename DROP UNUSED COLUMNS CHECKPOINT 1000;
--继续删除列选项
ALTER TABLE tablename DROP COLUMNS CONTINUE CHECKPOINT 1000;
--把表放到BUFFER_POOL中去
ALTER TABLE tablename STORAGE (BUFFER_POOL RECYCLE);
--避免动态分配EXTENT
ALTER TABLE tablename ALLOCATE EXTENT;
--把表放到CACHE中去
ALTER TABLE tablename ALLOCATE CACHE/NOCACHE;
4.索引管理
--创建索引
CREATE INDEX indexname ON TABLENAME(COLUMNNAME);
CREATE INDEX indexname ON TABLENAME(COLUMNNAME) TABLESPACE TABLESPACENAME;
--重新建立索引
ALTER INDEX indexname REBUILD TABLESPACE TABLESPACE;
--索引分配参数
ALTER INDEX indexnameSTORAGE(NEXT 400K MAXEXTENTS 100);
--释放索引空间
ALTER INDEX indexnameALLOCATE EXTENT (SIZE 200KDATAFILE '/DISK6/indx01.dbf');
ALTER INDEX indexnameDEALLOCATE UNUSED;
--重新整理索引表空间碎片
ALTER INDEX indexname COALESCE;
--删除索引
DROP INDEX indexname
--把索引放到BUFFER_POOL中
ALTER INDEX cust_name_idx REBUILD STORAGE (BUFFER_POOL KEEP);
5.约束管理
--建立主键
ALTER TABLE TABLENAMEADD CONSTRAINT CONSTRAINTNAME PRIMARY KEY(COLUMN1,COLUMN2)
--使约束无效
ALTER TABLE TABLENAME ENABLE NOVALIDATE CONSTRAINT constraintname;
ALTER TABLE TABLENAME ENABLE VALIDATE CONSTRAINT constraintname;
--删除约束
ALTER TABLE tablename DROP CONSTRAINT constraintname;
--删除表后将所用的外键删除
DROP TABLE tablename CASCADE CONSTRAINTS;
--给列增加缺省值
ALTER TABLE TABLENAMEMODIFY columnname DEFAULT(value) NOT NULL;
--给表增加外键
ALTER TABLE tablename ADD CONSTRAINT constraintname
FOREIGN KEY(column) REFERENCES table1name(column1);
6.安全策略
--加密传输
把客户端环境变量ora_encrypt_login设为true把服务器端参数dblink_encypt_login设为true
--数据库管理员安全策略
(1)建库后立即修改SYS/SYSTEM的口令(9.2后必须修改其口令)
(2)只有数据库管理员才能以SYSDBA登录系统
(3)建立不同角色的管理员,分配不同的权限
比如:对象创建于维护,数据库的调整与维护,创建用户分配角色,启动关闭,恢复备份
--应用开发者的安全策略
(1)开发者的特权只能在测试开发的数据库中赋予权限
(2)自由开发者、受控开发者
自由开发者:create table/index/procedure/package
受控开发者:没有以上权限
7.日志文件管理
--切换日志文件
ALTER SYSTEM SWITCH LOGFILE;
--增加日志文件
ALTER DATABASE ADD LOGFILE ('/DISK3/log3a.rdo','/DISK4/log3b.rdo') size 1M;
--增加日志成员
ALTER DATABASE ADD LOGFILE MEMBER'/DISK4/log1b.rdo' TO GROUP 1'/DISK4/log2b.rdo' TO GROUP 2;
--删除日志文件
ALTER DATABASE DROP LOGFILE GROUP 3;
--删除日志成员
ALTER DATABASE DROP LOGFILE MEMBER '/DISK4/log2b.dbf';
--清除日志文件内容
ALTER DATABASE CLEAR LOGFILE '/DISK3/log2a.rdo'; 转:http://www.cndba.cn/account/article/details/117
Oracle日常维护脚本的更多相关文章
- 程序员必备:Oracle日常维护命令
上一篇讲了Linux的日常维护命令,这篇讲讲Oracle的日常维护命令.工作中需要使用Oracle数据库的童鞋们,相信或多或少都需要对Oracle做一些基本的维护操作,例如导入导出总该有吧?( ...
- sqlserver日常维护脚本
SQL code --备份declare @sql varchar(8000) set @sql='backup database mis to disk=''d:\databack\mis\mis' ...
- oracle日常维护语句
1.如何查看数据库的状态 unix下 ps -ef | grep ora windows下 看服务是否起来 是否可以连上数据库 SQL> select status, instance_r ...
- ORACLE 日常维护命令手册
1查看数据库版本SELECT * FROM V$VERSION; 2查看数据库语言环境SELECT USERENV('LANGUAGE') FROM DUAL; 3查看ORACLE实例状态SELECT ...
- Oracle 史上最全近百条Oracle DBA日常维护SQL脚本指令
史上最全近百条Oracle DBA日常维护SQL脚本指令 https://mp.weixin.qq.com/s?__biz=MjM5MDAxOTk2MQ==&mid=2650281305&am ...
- oracle 容灾库日常维护 ,健康检查脚本 以及常见问题分析
select DEST_ID, APPLIED_SCN FROM v$archive_dest select * from v$dataguard_status; SELECT gvi.thread# ...
- ORACLE分区表梳理系列(二)- 分区表日常维护及注意事项(红字需要留意)
版权声明:本文发布于http://www.cnblogs.com/yumiko/,版权由Yumiko_sunny所有,欢迎转载.转载时,请在文章明显位置注明原文链接.若在未经作者同意的情况下,将本文内 ...
- MS SQL 日常维护管理常用脚本(二)
监控数据库运行 下面是整理.收集监控数据库运行的一些常用脚本,也是MS SQL 日常维护管理常用脚本(一)的续集,欢迎大家补充.提意见. 查看数据库登录名信息 Code Snippet SELEC ...
- Oracle 表空间的日常维护与管理
目录 Oracle 表空间的日常维护与管理 1.创建数据表空间 2.创建临时表空间 3.创建 UNDO 表空间 4.表空间的扩展与修改大小 5.表空间重命名 6.表空间的删除 7.更改表空间的读写模式 ...
随机推荐
- unity与Android相互调用
原地址:http://www.cnblogs.com/ayanmw/p/3727782.html 现在unity 导出的android客户端需要调用 Android 的支付SDK,但是unity与an ...
- G家二面
题目都很基本,都属于听说过但是不会做的…都是操作系统,compiler的概念题… 概念题郁闷就郁闷在不会就是不会,就算能扯两句也会被问倒… 算法就一个,pow(x, y),5分钟不到…… 不是听说G家 ...
- java基础知识回顾之---java String final类普通方法的应用之“子串在整串中出现的次数”
/* * 2 一个子串在整串中出现的次数. * "loveerlovetyloveuiloveoplove" * 思路: * 1,要找的子串是否存在,如果存在获取其出现的位置.这个 ...
- 【转载】synchronized 与 Lock 的那点事
最近在做一个监控系统,该系统主要包括对数据实时分析和存储两个部分,由于并发量比较高,所以不可避免的使用到了一些并发的知识.为了实现这些要求,后台使用一个队列作为缓存,对于请求只管往缓存里写数据.同时启 ...
- 李洪强iOS开发之零基础学习iOS开发【02-C语言】03-关键字、标识符、注释
上一讲中已经创建了第一个C语言程序,知道了C程序是由函数构成的,这讲继续学习C语言的一些基本语法.C语言属于一门高级语言,其实,所有的高级语言的基本语法组成部分都是一样的,只是表现形式不太一样.就好像 ...
- JAVA:23种设计模式详解(转)
设计模式(Design Patterns) ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了 ...
- 银联接口(注意项&备忘)
1,参考文档“证书下载.导出及上传流程.docx” 按照文档上所述,依次进行,导出的证书备用,用于配置文件的项“const SDK_ENCRYPT_CERT_PATH” 2,使用tp框架 新建一个控制 ...
- 只有innoDB才允许使用外键
1.只有InnoDB引擎才允许使用外键,所以,我们的数据表必须使用InnoDB引擎. 2.注意: 1.必须使用InnoDB引擎: 2.外键必须建立索引(INDEX): 3.外键绑定关系这里使用了“ O ...
- HTML5 增强的页面元素
一.HTML5 改良的 input 元素的种类 1.<input type="number" id="num1"> var n1 = documen ...
- 用 React 编写SVG图表
1.代码 <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="U ...