Thursday, January 8, 2009
Friday, January 2, 2009
Can Pregnant Women Use Ambosol For Toothaches
Some of the most difficult bugs we can find in a database is corrupted data blocks arise.
If we do get this error time will experience an increase in queries or receive ORA-01498 errors.
Oracle has several tools that help us identify and fix corrupted data that are occurring in a database:
a) ANALYZE TABLE table_name VALIDATE STRUCTURE.
b) DBVERIFY.
c) DB_BLOCK_CHECKING parameter.
d) DBMS_REPAIR
ANALYZE TABLE
This sentence is used to validate the structure of objects. If this statement returns an error means that there are bad blocks for that table.
sql>
MiSquema.Mitabla analyze table validate structure;
UTILITY DBVERIFY
is used to validate if there are bad blocks in a particular datafile. You need to tell by
pametro
blocksize block size that we set in the initialization parameter.
>
dbv blocksize = 8192 file = MiDatafile.dbf
DB_BLOCK_CHEKING
DB_BLOCK_CHEKING is an initialization parameter which forces or testing of the blocks each time a tablespace is to make a modification .
DBMS_REPAIR
This package allows to identify and fix the corrupt blocks in tables and indexes. This package is for a number of stored procedures:
CHECK_OBJECT: Detects if there are bad blocks on tables or indices.
FIX_CORRUPT_BLOCKS: Make those bad blocks.
DUMP_ORPHAN_KEYS: indicates those indices which were targeted by corrupt blocks. REBUILT_FREELISTS
SEGMENT_FIX_STATUS SKIP_CORRUPT_BLOCKS: You must use to avoid the ORA-1578 would return after fixing a corrupt block.
ADMIN_TABLES:
We will simulate the identification and fixing of corrupt data within a table: sql >
connect / as sysdba sql
>
MiSquema.Mitabla analyze table validate structure;
OUTPUT: ORA-1498
table_type => dbms_reparir.repair_table,
Check for bad blocks in the table.
rpr_count int DECLARE, BEGIN dbms_repair. Check_object
(schema_name => 'MiSquema' object_name => 'mytable'
repair_table_name => 'REPAIR_TABLE' corrupt_count => rpr_count) END
rpr_count stored in the number of corrupt blocks found.
The following query displays information about the object involved in the corrupt block.
sql> select object_name
, BLOCK_ID, corrupt_type, marked_corrupt, from REPAIR_TABLE;
Before marking the block as unusable should be a backup of the table.
sql> create table MiTable_back as select * from mytable WHERE
dbms_rowid.rowid_block_number (rowid) = 5
and dbms_rowid.rowid_to_absolute_fno (rowid, 'MiSquema', 'MyTable') = 4
mark the box as unusable: fix_block_count int DECLARE, BEGIN
fix_block_count: = 0;
dbms_repair. fix_corrupt_blocks ( schema_name => 'MiSquema'
object_name => 'mytable', object_type => dbms_repair.table_object, repair_table_name => 'REPAIR_TABLE'
fix_count => fix_block_count) END;
Reference: http://mogukiller.wordpress.com/2008/12/26/reparar-bloques-corruptos/
Scorpio Man Is He Flirting
TRANSACTION CONTROL DEFINITION: Set of operations dependent on each other that are made in the database. For the transaction is executed, must be carried out each and every one of the parties or transactions that compose it; In the event that any fault will fail the entire transaction. The user can define the beginning and end of a transaction.
IN ORACLE: .- transaction begins with the 1 st order SQL user session or the 1 st order after the end of the previous transaction.
.- ends when you run a command transaction control (commit or rollback), a command data definition (DDL) or when the session ends.
Once the transaction is not undoable.
COMMAND CONTROL
.- COMMIT TRANSACTION: terminating the transaction making the changes final, releasing the locked rows. Only after you run a commit other users have access to change data.
.- ROLLBACK: terminating the transaction by undoing the changes made and releasing the locked rows.
.- IMPLICIT ROLLBACK: When a program it fails to handle the exception that caused the failure. Melt all operations except those within the program have been confirmed.
.- SAVEPOINT
: Use with "rollback to" safeguard to score when processing transactions. This will undo some of a transaction.
.- ROLLBACK TO
: Undo the work done on the database after the point of preservation. However neither confirms the work done to the point of preservation. The transaction is not actually confirm or deny until there is a commit or a rollback.
I1 I2
P1 SAVEPOINT
P1 ROLLBACK TO COMMIT / ROLLBACK
scopes p1, p2 depend on the transaction.
· Transactions AUTONOMOUS
are those that can confirm or reject regardless of what happens in the current transaction. Conversely, what happens to the current transaction does not affect the self.
programs are used in small or blocks. meeting was declared in the declarative as
AUTONOMOUS_TRANSACTION PRAGMA; (Establishing the autonomous transaction) ... ... ... ... ... ... ... ... ... ... .... Commit / rollback;
UPDATE UPDATE
F (X) à pragma i1 i2 i3 i4 autonomous_transaction commit;
Rollback
UPDATE UPDATE
· TRANSACTIONS OF SOLO READING
are used to ensure consistency of data retrieved from different queries against any changes that may occur between them.
The beginning of a transaction read-only set with SET TRANSACTION READ ONLY. All queries will be executed only after those changes committed before the commencement of the transaction. (As if we did a picture of the BD). It confirms or rejects commit or rollback.
before a transaction is read only to do a rollback or commit or something to end the current transaction.
Rerenfia: http://www.lopezatienza.es/oracle/oracle-control-de-transacciones/
Why Cant I Hear My Microphone Samson R10s
If you recently upgraded your version of Oracle database to version 10g have noticed that the consultations grouped (GROUP BY) gives the results in any order.
Well, from the Oracle 10g the behavior of this clause has changed from its predecessors. Now using the new HASH GROUP BY mechanism, which does not guarantee that the result is in any order unless you use the clause "ORDER BY".
perform a test to verify this behavior
In Oracle 9i
OWNER COUNT (1)
CTXSYS 76 HR 25 MDSYS ODM
53 82 46 OE ODM_MTR 12
OLAPSYS 149
ORDSYS 7 OUTLN 6
Plan de Ejecución
SELECT STATEMENT CHOOSE 50 SORT GROUP BY
49 VIEW SYS.SYS_DBA_SEGS 48 UNION-ALL ……
En Oracle 10g
SQL> select owner,count(1) from dba_segments group by owner;
HR2 34 HABITAT 6 MDSYS 125
CTA_CTE1 392 RMAN 132
TSMSYS 4
DMSYS 4
DESIGNER6I 1902
DESIGNERTEST 1903
Plan de Ejecución
SELECT STATEMENT ALL_ROWSCost: 1.689 Bytes: 23.562 Cardinality: 1.386
45 HASH GROUP BY Cost: 1.689 Bytes: 23.562 Cardinality: 1.386
SYS.SYS_DBA_SEGS VIEW 44 VIEW Cost: 1.688 Bytes: 23.562 Cardinality: 1.386
43 UNION-ALL
As can be seen, the first result (oracle 9i) is given in ascending order, while the second (oracle 10g) result does not warrant any
can be seen in the implementation plans that use different mechanisms to resolve the query, while in first use "GROUP BY SORT", the second uses the new mechanism "HASH GROUP BY". Disabling
the "HASH GROUP BY" in oracle 10g
There are 2 ways to disable this behavior by group:
alter session set "_gby_hash_aggregation_enabled" = FALSE;
for oracle 9i version
A database level you can set the parameter
optimizer_features_enabled
alter system set
optimizer_features_enable = '9 .2.0 ';
Alter system set
optimizer_features_enable = '8 .1.7 ';
These latter configuration, does not require restarting the database.
References:
Metalink Note: 345048.1
http://searchoracle.techtarget.com/expert/KnowledgebaseAnswer/0, 289625, sid41_gci1251893, 00.html
Kates Playgroundskins.be
In certain circumstances a DBA should be able to create an Oracle database without the help of graphics utilities available in Oracle (DBCA).
is good to experiment with the manual creation of Oracle databases, as it delivers an experience that allows and decant understand many concepts about the functioning of the Oracle engine.
Steps to create an Oracle database: Decide
unique name for the instance, database name, Oracle block size, character set, maximum number of data files, and maximum number of files to redo. Decide
physical storage structure of the database (ASM, File System, Raw Devices). In the example uses storage by file system, and have defined and created the mount points according to Oracle OFA model.
Copy and edit the parameter file (init.ora) that allows you to initialize the Oracle instance.
Set appropriate operating system variables (ORACLE_SID), other variables such as ORACLE_HOME, ORACLE_BASE should be predefined.
Create password file (depending on the value that is defined for the parameter REMOTE_LOGIN_PASSWORDFILE)
Invoking SQLPLUS and connect to the database as sysdba. Start the instance
NOMOUNT state. This statement creates a new database.
Create the database (execute script creation the database)
Example parameter file *. inittest.ora
audit_file_dest = '/ u01/app/oracle/admin/test/adump' *.
background_dump_dest = '/ u01/app / oracle / admin / test / bdump '
*. compatible = '10 .2.0.1.0' *.
control_files = '/ u02/oradata/test/control01.ctl', '/ u02/oradata/test/control02. ctl ',' / u02/oradata/test/control03.ctl '*.
core_dump_dest =' / u01/app/oracle/admin/test/cdump '
db_block_size = 8192 *. *.
db_domain =' midominio.cl '
db_file_multiblock_read_count = 16 *.
*. db_name = 'test' *.
db_recovery_file_dest = '/ u01/app/oracle/flash_recovery_area' *.
db_recovery_file_dest_size = 2147483648 *. dispatchers = '(PROTOCOL = TCP) (SERVICE = testXDB)' *. job_queue_processes
= 10 *.
open_cursors = 300 = 92274688
pga_aggregate_target *. *. *. PROCESSES = 150
remote_login_passwordfile = 'EXCLUSIVE' *.
sga_target = 277872640 *. UNDO_MANAGEMENT = 'AUTO' *.
undo_tablespace = 'TS_UNDO' *.
user_dump_dest = '/ u01/app/oracle/admin/test/udump'
Creation Example Manual Oracle Database 9i
In the examples that follow has been prepared called inittest.ora file containing the parameters of the instance named test.
u01/app/oracle/database/oracle9iR2/dbs> sqlplus "/ as sysdba"
SQL * Plus: Release 9.2.0.2.0 - Production on Wed April 5
14:08:37 2006 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to an idle instance.
SQL> startup pfile = nomount? / Dbs / inittest.ora
ORACLE instance started.
Total System Global Area 160925320 bytes Fixed Size 730760 bytes
Variable Size 109051904 bytes
Database Buffers 50331648 bytes
Redo Buffers 811008 bytes
SQL> CREATE DATABASE test
LOGFILE group 1 (’/u01/oradata/test/redolog1a.dbf’,
‘/u02/oradata/test/redolog1b.dbf’ ) SIZE 10M,
group 2 (’/u01/oradata/test/redolog2a.dbf’,
‘/u02/oradata/test/redolog2b.dbf’ ) SIZE 10M,
group 3 (’/u01/oradata/test/redolog3a.dbf’,
‘/u02/oradata /test/redolog3b.dbf’ ) SIZE 10M
DATAFILE ‘/u02/oradata/test/system01.dbf’ SIZE 200M
CHARACTER SET WE8ISO8859P1 National character set utf8
EXTENT MANAGEMENT LOCAL ts_undo
undo tablespace datafile
'/ u02/oradata/test/undo01.dbf'
size 50M default temporary tablespace tempfile ts_temp
If the init.ora file is not in default location or has not been found with the pfile attribute, an error ORA-01078: failure in processing system parameters and it throws an error LRM-00109: could not open parameter file '/ u01/app/oracle/product/database/9.2.0/db_1/dbs/inittest.ora'
Creation Example Manual Oracle Database 10g
/ u01/app/oracle/product/database/10.2.0/db_1/dbs> sqlplus "/ as sysdba" SQL * Plus: Release 10.2.0.1.0 - Production on Wed April 2005 14:08: 37 2007 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to an idle instance.
SQL> startup pfile = nomount? / Dbs / inittest.ora
ORACLE instance started.
Total System Global Area 160925320 bytes
Fixed Size 730760 bytes
Variable Size 109051904 bytes
Database Buffers 50331648 bytes
Redo Buffers 811008 bytes
SQL> CREATE DATABASE test
‘/u02/oradata/test/redolog1b.dbf’ ) SIZE 10M, group 2 (’/u01/oradata/test/redolog2a.dbf’, ‘/u02/oradata/test/redolog2b.dbf’ ) SIZE 10M,
group 3 (’/u01/oradata/test/redolog3a.dbf’, ‘/u02/oradata /test/redolog3b.dbf’ ) SIZE 10M
DATAFILE ‘/u02/oradata/test/system01.dbf’ SIZE 200M CHARACTER SET WE8ISO8859P1 national character set utf8
EXTENT MANAGEMENT LOCAL SYSAUX datafile
'/ u02/oradata/test/sysaux01.dbf' size 300M
autoextend on next 10M maxsize unlimited undo tablespace datafile ts_undo
'/ u02/oradata/test/undo01.dbf 'size 50M default temporary tablespace tempfile ts_temp
' / u02/oradata/test/temp01.dbf 'size 50M
autoextend on next 50M maxsize 300M;
create database command also executes a file whose name is determined by the start parameter (hidden) _init_sql_file. After creating the database, it can be mounted and opened for use.
After creating a raw database, you must complete some additional tasks: Tasks
post
creation of the database
Once you have created the database to create database command, it must be supplemented by running some scripts to create the catalog and procedural option that allows you to execute PL / SQL. Run as SYS
·? / Rdbms / admin / catalog.sql
·? / Rdbms / admin / catproc.sql and
Where? represents a shortcut to the value of the $ ORACLE_HOME environment variable (only in sqlplus)
catalog.sql flame for example, catexp.sql which is a requirement for the exp utility for creating backups or dbmsstdx.sql logic which is a requirement to create triggers.
You can also run system? / Sqlplus / admin / pupbld.sql. pupbld.sql creates a table that allows you to block someone else to use sqlplus.
How To Lace Double Upper
From Oracle 8i there is functionality Oracle database called QUERY REWRITE, which under certain circumstances and settings configuration database objects, a SQL issued by a user is re-written by another equivalent that has the best cost. Consequently, this functionality is a requirement that the optimizer is configured as a CBO.
A common application for the use of QUERY REWRITE is given in data warehouse environments, where queries that use group functions on a fact table with millions of records can be resolved on a summary table (cardinality much smaller than fact table) containing the same information but with far fewer disk reads. summary tables listed should implement Materialized Views to take the property of QUERY REWRITE.
management system in a database that tracks the relational model, a view is a virtual table that represents the result of a query. Whenever you query or update a normal view, the RDBMS becomes these operations in queries or updates the tables used to define the view.
Example:
The following objects create a table plays fact table. It is created from an Oracle view catalog containing a large volume of records. REM Preparation table with large volume of records
sqlplus scott / tiger September echo on September
termout off drop table articles;
create table objectsNOLOGGING as select * from all_objects union all select
* from all_objects union all select * from all_objects
/ REM more data are added to the table to make it more bulky objects REM mechanism is used to accelerate DIRECT PATH settlement process
insert / * + APPEND * / into objects
select * from objects; commit; insert / * + APPEND * / into objects
commit;
objectsanalyze table compute statistics;
select count (*) from objects;REM
a query is made with the group functions on the table objects. SeptemberAutoTrace on September
timing on select owner, count (*) from articles group by owner;- OWNER COUNT (*) ---------- ———-
- CTXSYS 6264 ELAN 1272
- HR 816 MDSYS 5640
- ODM 9768 …
- 28 rows selected.
- Elapsed: 00:00:07.06
- Execution Plan ———————————————————-
(Cost=2719 Card=28 Bytes=140) 1 0 SORT (GROUP BY) (Cost=2719 Card=28 Bytes=140) 2 1 TABLE ACCESS (FULL) OF 'OBJECTS'
(Cost = 1226 Card = 708456 Bytes = 3542280)
is noted that the cost of this first implementation plan is high because the query requires to do a full table scan on a board of seven millions of records to retrieve only 28 records eventually. What can you do? Create a materialized view based on consultation and enable query rewrite. REM
privilege gives the user query rewrite SCOTT which will work
sqlplus / as sysdba grant
query rewrite to scott;
REM active for the current session the ability to query rewrite
sqlplus scott / tiger
alter session set query_rewrite_enabled = true; Alter session set
query_rewrite_integrity = enforced;
REM Note that materialized view allows query rewrite Materialized view
create vm_resumen_objetos
build
Immediate
refresh on commit enable query rewrite as
select owner, count (*) from objects
group by owner /
REM statistics are generated materialized view (CBO requirement) vm_resumen_objetos analyze table compute statistics;
REM now see in action the effect of the VM with the same query that is based VM
AutoTrace
September traceonly
select owner, count (*) from objects
group by owner;
September AutoTrace off timing off
Elapsed: 00:00:00.03 Execution Plan
(Cost = 2 Card = 28 Bytes = 252)
1 0 TABLE ACCESS (FULL) OF 'VM_RESUMEN_OBJETOS'
(Cost = 2 Card = 28 Bytes = 252)
is noted that the cost of implementing this second plan is much less than the cost at the plan original implementation which is a result of the great impact it has on This second query performance. This is the fundamental idea of \u200b\u200bthe QUERY REWRITE.