标签云
asm 恢复 asm恢复 bbed bootstrap$ dul In Memory kcbzib_kcrsds_1 kccpb_sanity_check_2 kfed MySQL恢复 ORA-00312 ORA-00607 ORA-00704 ORA-01110 ORA-01555 ORA-01578 ORA-08103 ORA-600 2662 ORA-600 2663 ORA-600 3020 ORA-600 4000 ORA-600 4137 ORA-600 4193 ORA-600 4194 ORA-600 16703 ORA-600 kcbzib_kcrsds_1 ORA-600 KCLCHKBLK_4 ORA-15042 ORA-15196 ORACLE 12C oracle dul ORACLE PATCH Oracle Recovery Tools oracle加密恢复 oracle勒索 oracle勒索恢复 oracle异常恢复 ORACLE恢复 Oracle 恢复 ORACLE数据库恢复 oracle 比特币 OSD-04016 YOUR FILES ARE ENCRYPTED 勒索恢复 比特币加密文章分类
- Others (2)
- 中间件 (2)
- WebLogic (2)
- 操作系统 (100)
- 数据库 (1,598)
- DB2 (22)
- MySQL (70)
- Oracle (1,463)
- Data Guard (49)
- EXADATA (7)
- GoldenGate (21)
- ORA-xxxxx (158)
- ORACLE 12C (72)
- ORACLE 18C (6)
- ORACLE 19C (13)
- ORACLE 21C (3)
- Oracle ASM (65)
- Oracle Bug (7)
- Oracle RAC (47)
- Oracle 安全 (6)
- Oracle 开发 (27)
- Oracle 监听 (27)
- Oracle备份恢复 (530)
- Oracle安装升级 (84)
- Oracle性能优化 (62)
- 专题索引 (5)
- 勒索恢复 (75)
- PostgreSQL (18)
- PostgreSQL恢复 (6)
- SQL Server (27)
- SQL Server恢复 (8)
- TimesTen (7)
- 达梦数据库 (2)
- 生活娱乐 (2)
- 至理名言 (11)
- 虚拟化 (2)
- VMware (2)
- 软件开发 (36)
- Asp.Net (9)
- JavaScript (12)
- PHP (2)
- 小工具 (19)
-
最近发表
- PostgreSQL解析wal日志之—walminer
- Oracle 19c/21c最新patch信息-202404
- PostgreSQL恢复系列:pg_filedump批量处理
- PostgreSQL部分主要字典信息
- PostgreSQL恢复系列:pg_filedump恢复字典构造
- PostgreSQL 16 源码安装
- ORA-00742 ORA-00312 恢复
- 数据库open成功后报ORA-00353 ORA-00354错误引起的一系列问题(本质ntfs文件系统异常)
- ORA-600 ktsiseginfo1故障
- ORA-00600: internal error code, arguments: [16703], [1403], [4] 原因
- 最近遇到几起ORA-600 16703故障(tab$被清空),请引起重视
- ORA-600 2662快速恢复之Patch scn工具
- TNS-12518: TNS:listener could not hand off client connection
- ora.storage无法启动报ORA-12514故障处理
- 断电引起文件scn异常数据库恢复
- ORA-16188: LOG_ARCHIVE_CONFIG settings inconsistent with previously started instance
- .[hudsonL@cock.li].mkp勒索加密数据库完美恢复
- 模拟带库实现rman远程备份
- 又一例:ORA-600 kclchkblk_4和2662故障
- Oracle误删除数据文件恢复
月归档:九月 2011
TOM的SHOW_SPACE过程使用
TOM写了个好工具SHOW_SPACE,这个工具对于Oracle来讲其实就是个存储过程,这个存储过程可以用来分析空间使用情况,有了此工具,就不用再通过写SQL语句来看每条记录或表占用表空间的大小了,使用起来很方便。
create or replace procedure show_space ( p_segname_1 in varchar2, p_owner_1 in varchar2 default user, p_type_1 in varchar2 default 'TABLE', p_space in varchar2 default 'AUTO', p_analyzed in varchar2 default 'Y' ) as p_segname varchar2(100); p_type varchar2(10); p_owner varchar2(30); l_unformatted_blocks number; l_unformatted_bytes number; l_fs1_blocks number; l_fs1_bytes number; l_fs2_blocks number; l_fs2_bytes number; l_fs3_blocks number; l_fs3_bytes number; l_fs4_blocks number; l_fs4_bytes number; l_full_blocks number; l_full_bytes number; l_free_blks number; l_total_blocks number; l_total_bytes number; l_unused_blocks number; l_unused_bytes number; l_LastUsedExtFileId number; l_LastUsedExtBlockId number; l_LAST_USED_BLOCK number; procedure p( p_label in varchar2, p_num in number ) is begin dbms_output.put_line( rpad(p_label,40,'.') || p_num ); end; begin p_segname := upper(p_segname_1); -- rainy changed p_owner := upper(p_owner_1); p_type := p_type_1; if (p_type_1 = 'i' or p_type_1 = 'I') then --rainy changed p_type := 'INDEX'; end if; if (p_type_1 = 't' or p_type_1 = 'T') then --rainy changed p_type := 'TABLE'; end if; if (p_type_1 = 'c' or p_type_1 = 'C') then --rainy changed p_type := 'CLUSTER'; end if; dbms_space.unused_space ( segment_owner => p_owner, segment_name => p_segname, segment_type => p_type, total_blocks => l_total_blocks, total_bytes => l_total_bytes, unused_blocks => l_unused_blocks, unused_bytes => l_unused_bytes, LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId, LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId, LAST_USED_BLOCK => l_LAST_USED_BLOCK ); if p_space = 'MANUAL' or (p_space <> 'auto' and p_space <> 'AUTO') then dbms_space.free_blocks ( segment_owner => p_owner, segment_name => p_segname, segment_type => p_type, freelist_group_id => 0, free_blks => l_free_blks ); p( 'Free Blocks', l_free_blks ); end if; p( 'Total Blocks', l_total_blocks ); p( 'Total Bytes', l_total_bytes ); p( 'Unused Blocks', l_unused_blocks ); p( 'Unused Bytes', l_unused_bytes ); p( 'Last Used Ext FileId', l_LastUsedExtFileId ); p( 'Last Used Ext BlockId', l_LastUsedExtBlockId ); p( 'Last Used Block', l_LAST_USED_BLOCK ); /*IF the segment is analyzed */ if p_analyzed = 'Y' then dbms_space.space_usage(segment_owner => p_owner , segment_name => p_segname , segment_type => p_type , unformatted_blocks => l_unformatted_blocks , unformatted_bytes => l_unformatted_bytes, fs1_blocks => l_fs1_blocks, fs1_bytes => l_fs1_bytes , fs2_blocks => l_fs2_blocks, fs2_bytes => l_fs2_bytes, fs3_blocks => l_fs3_blocks , fs3_bytes => l_fs3_bytes, fs4_blocks => l_fs4_blocks, fs4_bytes => l_fs4_bytes, full_blocks => l_full_blocks, full_bytes => l_full_bytes); dbms_output.put_line(rpad(' ',50,'*')); dbms_output.put_line('The segment is analyzed'); p( '0% -- 25% free space blocks', l_fs1_blocks); p( '0% -- 25% free space bytes', l_fs1_bytes); p( '25% -- 50% free space blocks', l_fs2_blocks); p( '25% -- 50% free space bytes', l_fs2_bytes); p( '50% -- 75% free space blocks', l_fs3_blocks); p( '50% -- 75% free space bytes', l_fs3_bytes); p( '75% -- 100% free space blocks', l_fs4_blocks); p( '75% -- 100% free space bytes', l_fs4_bytes); p( 'Unused Blocks', l_unformatted_blocks ); p( 'Unused Bytes', l_unformatted_bytes ); p( 'Total Blocks', l_full_blocks); p( 'Total bytes', l_full_bytes); end if; end; /
用法
SQL> create table t 2 as 3 select * from dba_objects; Table created. SQL> set serverout on SQL> exec show_space('T','TEST'); Total Blocks............................768 Total Bytes.............................6291456 Unused Blocks...........................52 Unused Bytes............................425984 Last Used Ext FileId....................4 Last Used Ext BlockId...................1033 Last Used Block.........................76 ************************************************* The segment is analyzed 0% -- 25% free space blocks.............0 0% -- 25% free space bytes..............0 25% -- 50% free space blocks............0 25% -- 50% free space bytes.............0 50% -- 75% free space blocks............0 50% -- 75% free space bytes.............0 75% -- 100% free space blocks...........0 75% -- 100% free space bytes............0 Unused Blocks...........................0 Unused Bytes............................0 Total Blocks............................696 Total bytes.............................5701632 PL/SQL procedure successfully completed. SQL> delete from t; 50602 rows deleted. SQL> exec show_space('T','TEST'); Total Blocks............................768 Total Bytes.............................6291456 Unused Blocks...........................52 Unused Bytes............................425984 Last Used Ext FileId....................4 Last Used Ext BlockId...................1033 Last Used Block.........................76 ************************************************* The segment is analyzed 0% -- 25% free space blocks.............0 0% -- 25% free space bytes..............0 25% -- 50% free space blocks............0 25% -- 50% free space bytes.............0 50% -- 75% free space blocks............0 50% -- 75% free space bytes.............0 75% -- 100% free space blocks...........696 75% -- 100% free space bytes............5701632 Unused Blocks...........................0 Unused Bytes............................0 Total Blocks............................0 Total bytes.............................0 PL/SQL procedure successfully completed. SQL> alter table t move; Table altered. SQL> exec show_space('T','TEST'); Total Blocks............................8 Total Bytes.............................65536 Unused Blocks...........................5 Unused Bytes............................40960 Last Used Ext FileId....................4 Last Used Ext BlockId...................401 Last Used Block.........................3 ************************************************* The segment is analyzed 0% -- 25% free space blocks.............0 0% -- 25% free space bytes..............0 25% -- 50% free space blocks............0 25% -- 50% free space bytes.............0 50% -- 75% free space blocks............0 50% -- 75% free space bytes.............0 75% -- 100% free space blocks...........0 75% -- 100% free space bytes............0 Unused Blocks...........................0 Unused Bytes............................0 Total Blocks............................0 Total bytes.............................0 PL/SQL procedure successfully completed.
发表在 Oracle
评论关闭
ORA-02266: unique/primary keys in table referenced by enabled foreign keys
truncate清空一张表记录发现ORA-02266,进行模拟测试
SQL> truncate table p; truncate table p * ERROR at line 1: ORA-02266: unique/primary keys in table referenced by enabled foreign keys --错误原因 SQL> !oerr ora 02266 02266, 00000, "unique/primary keys in table referenced by enabled foreign keys" // *Cause: An attempt was made to truncate a table with unique or // primary keys referenced by foreign keys enabled in another table. // Other operations not allowed are dropping/truncating a partition of a // partitioned table or an ALTER TABLE EXCHANGE PARTITION. // *Action: Before performing the above operations the table, disable the // foreign key constraints in other tables. You can see what // constraints are referencing a table by issuing the following // command: // SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = "tabnam"; --查询是否有主键或者唯一index SET SERVEROUTPUT ON SET LINESIZE 1000 SET FEEDBACK OFF SET LONG 999999 SET PAGESIZE 1000 EXEC DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);--不显示存储信息 SQL> SELECT DBMS_METADATA.GET_DDL('TABLE','P') FROM DUAL; DBMS_METADATA.GET_DDL('TABLE','P') -------------------------------------------------------------------------------- CREATE TABLE "CHF"."P" ( "X" NUMBER(*,0), PRIMARY KEY ("X") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 TABLESPACE "USERS" ENABLE ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING TABLESPACE "USERS --查询主外键关系 SQL> col 主键表名 for a20 SQL> col 主键列名 for a20 SQL> col 外键表名 for a20 SQL> col 外键列名 for a20 SQL> select b.table_name 主键表名, b.column_name 主键列名, a.table_name 外键表名, a.column_name 外键列名 from (select a.constraint_name, b.table_name, b.column_name, a.r_constraint_name from dba_constraints a, dba_cons_columns b WHERE a.constraint_type = 'R' and a.constraint_name = b.constraint_name) a, (select distinct a.r_constraint_name, b.table_name, b.column_name from dba_constraints a, dba_cons_columns b WHERE a.constraint_type = 'R' and a.r_constraint_name = b.constraint_name) b where a.r_constraint_name = b.r_constraint_name and b.table_name='P'; 主键表名 主键列名 外键表名 外键列名 -------------------- -------------------- -------------------- -------------------- P X C X 1 row selected. --处理方法一 SQL> alter table p disable primary key cascade; Table altered. SQL> truncate table p; Table truncated. SQL> alter table p enable primary key; Table altered. --处理方法二 SQL> delete from t; 1 row deleted. SQL> commit; Commit complete.
自治事件引起死锁
今天遇到一个比较特殊的死锁现象,记录下来
DEADLOCK DETECTED ( ORA-00060 ) [Transaction Deadlock] The following deadlock is not an ORACLE error. It is a deadlock due to user error in the design of an application or from issuing incorrect ad-hoc SQL. The following information may aid in determining the deadlock: Deadlock graph: ---------Blocker(s)-------- ---------Waiter(s)--------- Resource Name process session holds waits process session holds waits TX-00090022-000002ba 15 145 X 15 145 X session 145: DID 0001-000F-00000019 session 145: DID 0001-000F-00000019 Rows waited on: Session 145: obj - rowid = 0000E0A3 - AAAOCjAAFAAAAA8AAA (dictionary objn - 57507, file - 5, block - 60, slot - 0) Information on the OTHER waiting sessions: End of information on OTHER waiting sessions. Current SQL statement for this session: UPDATE T SET Y = Y WHERE X = :B1 ----- PL/SQL Call Stack ----- object line object handle number name 0x67987910 4 CHF.T ===================================================
问题原因:自治事件导致(重现)
drop table t; create table t ( x int, y int ); create or replace trigger t before update on t for each row declare pragma autonomous_transaction; begin update t set y = y where x = :new.x; commit; end; / insert into t values ( 1, 1 ); commit; update t set y = y where x = 1;