如果執(zhí)行了數(shù)據(jù)庫(kù)恢復(fù)操作,日志序列號(hào)會(huì)歸零。你可以這樣查
創(chuàng)新互聯(lián)建站專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站設(shè)計(jì)制作、網(wǎng)站設(shè)計(jì)、陸川網(wǎng)絡(luò)推廣、重慶小程序開發(fā)、陸川網(wǎng)絡(luò)營(yíng)銷、陸川企業(yè)策劃、陸川品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)建站為所有大學(xué)生創(chuàng)業(yè)者提供陸川建站搭建服務(wù),24小時(shí)服務(wù)熱線:13518219792,官方網(wǎng)址:www.cdcxhl.com
select * from v$log;
看sequence#這一列。
至于回滾不容易看吧,那是事務(wù)級(jí)別的。
朋友:
oracle中有兩樣?xùn)|西是用來(lái)記錄歷史的
一、重做日志 REDO(作用就是當(dāng)你8點(diǎn)做了很多事情,到10點(diǎn)由于數(shù)據(jù)庫(kù)8點(diǎn)到10點(diǎn)操作的某個(gè)文件壞了,那么8點(diǎn)到10點(diǎn)的的東西全都不見了,但是REDO還在。你就可以用REDO來(lái)做重做你8點(diǎn)到10點(diǎn)所做的事,REDO就是記錄了這樣的事!)
二、回滾段 UNDO (作用就是當(dāng)你后悔做了某些事之后就可以回到以前,但是在人間可是沒有后悔要賣的哦。如你無(wú)意刪除一個(gè)表,你就可以用rollback命令來(lái)回滾,它利用的就是oracle 的撤消表空間記錄的內(nèi)容。當(dāng)然這個(gè)表空間滿了的時(shí)候也就不能回滾到它沒記錄的內(nèi)容了。)
Oracle常用視圖
1 Oracle常用數(shù)據(jù)字典表
1、 查看當(dāng)前用戶的缺省表空間
SQLselect username,default_tablespace from user_users;
2、 查看當(dāng)前用戶的角色
SQLselect * from user_role_privs;
3、 查看當(dāng)前用戶的系統(tǒng)權(quán)限和表級(jí)權(quán)限
SQLselect * from user_sys_privs;
SQLselect * from user_tab_privs;
4、 查看用戶下所有的表
SQLselect * from user_tables;
5、 查看用戶下所有的表的列屬性
SQLselect * from USER_TAB_COLUMNS where table_name=:table_Name;
6、 顯示用戶信息(所屬表空間)
select default_tablespace, temporary_tablespace
from dba_users
where username = 'GAME';
7、 顯示當(dāng)前會(huì)話所具有的權(quán)限
SQLselect * from session_privs;
8、 顯示指定用戶所具有的系統(tǒng)權(quán)限
SQLselect * from dba_sys_privs where grantee='GAME';
9、 顯示特權(quán)用戶
select * from v$pwfile_users;
10、 顯示用戶信息(所屬表空間)
select default_tablespace,temporary_tablespace
from dba_users where username='GAME';
11、 顯示用戶的PROFILE
select profile from dba_users where username='GAME';
2 表
1、 查看用戶下所有的表
SQLselect * from user_tables;
2、 查看名稱包含log字符的表
SQLselect object_name,object_id from user_objects
where instr(object_name,'LOG')0;
3、 查看某表的創(chuàng)建時(shí)間
SQLselect object_name,created from user_objects where object_name=upper('table_name');
4、 查看某表的大小
SQLselect sum(bytes)/(1024*1024) as "size(M)" from user_segments
where segment_name=upper('table_name');
5、 查看放在Oracle的內(nèi)存區(qū)里的表
SQLselect table_name,cache from user_tables where instr(cache,'Y')0;
3 索引
1、 查看索引個(gè)數(shù)和類別
SQLselect index_name,index_type,table_name from user_indexes order by table_name;
2、 查看索引被索引的字段
SQLselect * from user_ind_columns where index_name=upper('index_name');
3、 查看索引的大小
SQLselect sum(bytes)/(1024*1024) as "size(M)" from user_segments
where segment_name=upper('index_name');
4 序列號(hào)
1、 查看序列號(hào),last_number是當(dāng)前值
SQLselect * from user_sequences;
5 視圖
1、 查看視圖的名稱
SQLselect view_name from user_views;
2、 查看創(chuàng)建視圖的select語(yǔ)句
SQLset view_name,text_length from user_views;
SQLset long 2000; 說(shuō)明:可以根據(jù)視圖的text_length值設(shè)定set long 的大小
SQLselect text from user_views where view_name=upper('view_name');
6 同義詞
1、 查看同義詞的名稱
SQLselect * from user_synonyms;
7 約束條件
1、 查看某表的約束條件
SQLselect constraint_name, constraint_type,search_condition, r_constraint_name
from user_constraints where table_name = upper('table_name');
SQLselect c.constraint_name,c.constraint_type,cc.column_name
from user_constraints c,user_cons_columns cc
where c.owner = upper('table_owner') and c.table_name = upper('table_name')
and c.owner = cc.owner and c.constraint_name = cc.constraint_name
order by cc.position;
8 存儲(chǔ)函數(shù)和過(guò)程
1、 查看函數(shù)和過(guò)程的狀態(tài)
SQLselect object_name,status from user_objects where object_type='FUNCTION';
SQLselect object_name,status from user_objects where object_type='PROCEDURE';
2、 查看函數(shù)和過(guò)程的源代碼
SQLselect text from all_source where owner=user and name=upper('plsql_name');
9 常用的數(shù)據(jù)字典:
dba_data_files:通常用來(lái)查詢關(guān)于數(shù)據(jù)庫(kù)文件的信息
dba_db_links:包括數(shù)據(jù)庫(kù)中的所有數(shù)據(jù)庫(kù)鏈路,也就是databaselinks。
dba_extents:數(shù)據(jù)庫(kù)中所有分區(qū)的信息
dba_free_space:所有表空間中的自由分區(qū)
dba_indexs:關(guān)于數(shù)據(jù)庫(kù)中所有索引的描述
dba_ind_columns:在所有表及聚集上壓縮索引的列
dba_objects:數(shù)據(jù)庫(kù)中所有的對(duì)象
dba_rollback_segs:回滾段的描述
dba_segments:所有數(shù)據(jù)庫(kù)段分段的存儲(chǔ)空間
dba_synonyms:關(guān)于同義詞的信息查詢
dba_tables:數(shù)據(jù)庫(kù)中所有數(shù)據(jù)表的描述
dba_tabespaces:關(guān)于表空間的信息
dba_tab_columns:所有表描述、視圖以及聚集的列
dba_tab_grants/privs:對(duì)象所授予的權(quán)限
dba_ts_quotas:所有用戶表空間限額
dba_users:關(guān)于數(shù)據(jù)的所有用戶的信息
dba_views:數(shù)據(jù)庫(kù)中所有視圖的文本
10 常用的動(dòng)態(tài)性能視圖:
v$datafile:數(shù)據(jù)庫(kù)使用的數(shù)據(jù)文件信息
v$librarycache:共享池中SQL語(yǔ)句的管理信息
v$lock:通過(guò)訪問(wèn)數(shù)據(jù)庫(kù)會(huì)話,設(shè)置對(duì)象鎖的所有信息
v$log:從控制文件中提取有關(guān)重做日志組的信息
v$logfile有關(guān)實(shí)例重置日志組文件名及其位置的信息
v$parameter:初始化參數(shù)文件中所有項(xiàng)的值
v$process:當(dāng)前進(jìn)程的信息
v$rollname:回滾段信息
v$rollstat:聯(lián)機(jī)回滾段統(tǒng)計(jì)信息
v$rowcache:內(nèi)存中數(shù)據(jù)字典活動(dòng)/性能信息
v$session:有關(guān)會(huì)話的信息
v$sesstat:在v$session中報(bào)告當(dāng)前會(huì)話的統(tǒng)計(jì)信息
v$sqlarea:共享池中使用當(dāng)前光標(biāo)的統(tǒng)計(jì)信息,光標(biāo)是一塊內(nèi)存區(qū)域,有Oracle處理SQL語(yǔ)句時(shí)打開。
v$statname:在v$sesstat中報(bào)告各個(gè)統(tǒng)計(jì)的含義
v$sysstat:基于當(dāng)前操作會(huì)話進(jìn)行的系統(tǒng)統(tǒng)計(jì)
v$waitstat:出現(xiàn)一個(gè)以上會(huì)話訪問(wèn)數(shù)據(jù)庫(kù)的數(shù)據(jù)時(shí)的詳細(xì)情況。當(dāng)有一個(gè)以上的會(huì)話訪問(wèn)同一信息時(shí),可出現(xiàn)等待情況。
總結(jié)了一下這些,徹底區(qū)別了視圖與數(shù)據(jù)字典,也不那么容易混淆。嘿嘿!!!
11 常用SQL查詢:
1、查看表空間的名稱及大小
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
2、查看表空間物理文件的名稱及大小
select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name;
3、查看回滾段名稱及大小
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;
4、查看控制文件
select name from v$controlfile;
5、查看日志文件
select member from v$logfile;
6、查看表空間的使用情況
select sum(bytes)/(1024*1024) as free_space,tablespace_name
from dba_free_space
group by tablespace_name;
SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE,
(B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE"
FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;
7、查看數(shù)據(jù)庫(kù)庫(kù)對(duì)象
select owner, object_type, status, count(*) count# from all_objects group by owner, object_type, status;
8、查看數(shù)據(jù)庫(kù)的版本
Select version FROM Product_component_version
Where SUBSTR(PRODUCT,1,6)='Oracle';
9、查看數(shù)據(jù)庫(kù)的創(chuàng)建日期和歸檔方式
Select Created, Log_Mode, Log_Mode From V$Database;
10、捕捉運(yùn)行很久的SQL
column username format a12
column opname format a16
column progress format a8
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
11。查看數(shù)據(jù)表的參數(shù)信息
SELECT partition_name, high_value, high_value_length, tablespace_name,
pct_free, pct_used, ini_trans, max_trans, initial_extent,
next_extent, min_extent, max_extent, pct_increase, FREELISTS,
freelist_groups, LOGGING, BUFFER_POOL, num_rows, blocks,
empty_blocks, avg_space, chain_cnt, avg_row_len, sample_size,
last_analyzed
FROM dba_tab_partitions
--WHERE table_name = :tname AND table_owner = :towner
ORDER BY partition_position
12.查看還沒提交的事務(wù)
select * from v$locked_object;
select * from v$transaction;
13。查找object為哪些進(jìn)程所用
select
p.spid,
s.sid,
s.serial# serial_num,
s.username user_name,
a.type object_type,
s.osuser os_user_name,
a.owner,
a.object object_name,
decode(sign(48 - command),
1,
to_char(command), 'Action Code #' || to_char(command) ) action,
p.program oracle_process,
s.terminal terminal,
s.program program,
s.status session_status
from v$session s, v$access a, v$process p
where s.paddr = p.addr and
s.type = 'USER' and
a.sid = s.sid and
a.object='SUBSCRIBER_ATTR'
order by s.username, s.osuser
14?;貪L段查看
select rownum, sys.dba_rollback_segs.segment_name Name, v$rollstat.extents
Extents, v$rollstat.rssize Size_in_Bytes, v$rollstat.xacts XActs,
v$rollstat.gets Gets, v$rollstat.waits Waits, v$rollstat.writes Writes,
sys.dba_rollback_segs.status status from v$rollstat, sys.dba_rollback_segs,
v$rollname where v$rollname.name(+) = sys.dba_rollback_segs.segment_name and
v$rollstat.usn (+) = v$rollname.usn order by rownum
15。耗資源的進(jìn)程(top session)
select s.schemaname schema_name, decode(sign(48 - command), 1,
to_char(command), 'Action Code #' || to_char(command) ) action, status
session_status, s.osuser os_user_name, s.sid, p.spid , s.serial# serial_num,
nvl(s.username, '[Oracle process]') user_name, s.terminal terminal,
s.program program, st.value criteria_value from v$sesstat st, v$session s , v$process p
where st.sid = s.sid and st.statistic# = to_number('38') and ('ALL' = 'ALL'
or s.status = 'ALL') and p.addr = s.paddr order by st.value desc, p.spid asc, s.username asc, s.osuser asc
16。查看鎖(lock)情況
select /*+ RULE */ ls.osuser os_user_name, ls.username user_name,
decode(ls.type, 'RW', 'Row wait enqueue lock', 'TM', 'DML enqueue lock', 'TX',
'Transaction enqueue lock', 'UL', 'User supplied lock') lock_type,
o.object_name object, decode(ls.lmode, 1, null, 2, 'Row Share', 3,
'Row Exclusive', 4, 'Share', 5, 'Share Row Exclusive', 6, 'Exclusive', null)
lock_mode, o.owner, ls.sid, ls.serial# serial_num, ls.id1, ls.id2
from sys.dba_objects o, ( select s.osuser, s.username, l.type,
l.lmode, s.sid, s.serial#, l.id1, l.id2 from v$session s,
v$lock l where s.sid = l.sid ) ls where o.object_id = ls.id1 and o.owner
'SYS' order by o.owner, o.object_name
17。查看等待(wait)情況
SELECT v$waitstat.class, v$waitstat.count count, SUM(v$sysstat.value) sum_value
FROM v$waitstat, v$sysstat WHERE v$sysstat.name IN ('db block gets',
'consistent gets') group by v$waitstat.class, v$waitstat.count
18。查看sga情況
SELECT NAME, BYTES FROM SYS.V_$SGASTAT ORDER BY NAME ASC
19。查看catched object
SELECT owner, name, db_link, namespace,
type, sharable_mem, loads, executions,
locks, pins, kept FROM v$db_object_cache
20。查看V$SQLAREA
SELECT SQL_TEXT, SHARABLE_MEM, PERSISTENT_MEM, RUNTIME_MEM, SORTS,
VERSION_COUNT, LOADED_VERSIONS, OPEN_VERSIONS, USERS_OPENING, EXECUTIONS,
USERS_EXECUTING, LOADS, FIRST_LOAD_TIME, INVALIDATIONS, PARSE_CALLS, DISK_READS,
BUFFER_GETS, ROWS_PROCESSED FROM V$SQLAREA
1、將數(shù)據(jù)關(guān)閉 svrmgrl Shutdown abort2、修改初始化參數(shù)文件 $ vi $ORACLE_HOME/dbs/init sid .ora添加以下參數(shù) rollback_segments=(system) _corrupted_rollback_segments=(r01,r02,r03,r04) _allow_resetlogs_corruption=ture3、重新裝載數(shù)據(jù)庫(kù) svrmgrl Startup mount4、從數(shù)據(jù)庫(kù)的控制文件中將回滾段表空間rbs的數(shù)據(jù)文件離線并去掉。 svrmgrl recover database using backup controlfile;---- 此時(shí)屏幕上可能會(huì)出現(xiàn): ORA_00280 Change #### for thread# is in sequence# specify log:[ RET for suggested|AUTO|from logsource|cancel]輸入cancel(不要輸入其他命令) svrmgrl alter database open resetlogs;5、 重建新的回滾段 ---- 將舊回滾段及回滾表空間刪除。 svrmgrl connect internal svrmgrl create rollback segment ro tablespace system; svrmgrl alter rollback segment ro online; svrmgrl create tablespace rbs datafile ##/##/rbs01.dbf’ size ##k; svrmgrl create rollback segment r01 tablespace rbs; svrmgrl create rollback segment r02 tablespace rbs; svrmgrl create rollback segment r03 tablespace rbs; svrmgrl create rollback segment r04 tablespace rbs; svrmgrl alter rollback segment r01 online; svrmgrl alter rollback segment r02 online; svrmgrl alter rollback segment r03 online; svrmgrl alter rollback segment r04 online; svrmgrl Shutdown abort $ vi $ORACLE_HOME/dbs/init sid .ora rollback_segments=(r01,r02,r03,r04) 將參數(shù)_corrupted_rollback_segment _allow_resetlogs_corruption=true去掉 svrmgrl Startup normal(T114)
你先用系統(tǒng)system回滾段進(jìn)去,把回滾表空間刪掉,然后重建,在改回來(lái)應(yīng)該好了