DML statistics, oracle - oracle

Does oracle (11g at least, but it would be nice if 10g too) have some statistics on DML been performed?
What I expect to get is: for table A in schema B it was performed I inserts, J updates, K deletes from date1 to date2

You can use the monitoring feature and the dba_tab_modifications table to get that information. See for example here or here.

Related

how works DBA_TAB_MODIFICATIONS

I wonder how works the DBA_TAB_MODIFICATIONS.
How long is kept the data for a table? I have tables with timestamp
on Dec/2019
What does it mean when a table is not in
DBA_TAB_MODIFICATIONS? do it mean the table hasn't had (delete,
insert, update) in a period? if yes, for how long?
I have a Schema with around 1000 tables, only around 300 appear in
DBA_TAB_MODIFICATIONS
DBA_TAB_MODIFICATIONS is used by Oracle internally to track how many inserts, updates and deletes have been done to a table or table partition since the stats had been gathered on it with dbms_stats.
What version of Oracle are you using because after Oracle 9 it is automatically inserted
into the DBA_TAB_MODIFICATIONS table, before oracle 9 you have to register a table as MONITORED.

Oracle DB Audit ALL

I have a 5TB large database.
I want to audit everything , really everything.
First of all, I tried with AUDIT ALL, but according to Oracle's document AUDIT ALL does NOT audit everything...
I know that this statement must be executed in order to start auditing db:
alter system set audit_trail=db,extended scope=spfile;
But what else should I do to start auditing all the SQL statements that users execute?
You need not to use the AUDIT feature if you only want a view on user queries (SELECT, UPDATE, INSERT) on your database. $AUD contains rather DDL statements, whereas V$SQL contains only DML statements.
A very simple solution is to use another view: V$SQL. You can extract duration and lot of useful info from it.
Useful example:
SELECT * FROM v$sql vv
WHERE lower(vv.SQL_TEXT) like '%delete%'
AND vv.PARSING_SCHEMA_NAME like 'A_SCHEMA%'
ORDER BY vv.LAST_ACTIVE_TIME desc;
V$SQL lists statistics on shared SQL area without the GROUP BY clause and contains one row for each child of the original SQL text entered. Statistics displayed in V$SQL are normally updated at the end of query execution.
Long running queries are updated every 5 seconds. This shows the impact of long running SQLs while they are still working.

Recording sql statements performing on a table in Oracle

Is there a way to record sql statements performing on table in Oracle? I need to record those queries for a table in production and hopefully rerun them in my test to make sure I don't mess up table modification.
Thanks,
Sean
Oracle Database Replay is exactly the feature you are looking for: http://www.oracle.com/technetwork/articles/sql/11g-replay-099279.html
Oracle automatically records any SQL executed against the instance in a table called v$sqlarea

Obtain Oracle 11g partitioning interval by direct system table query

I've got a table which is partitioned on a NUMBER variable in Oracle 11g, with the INTERVAL set to 1. On our development system I can execute
SELECT DBMS_METADATA.GET_DDL('TABLE', 'TABLE_NAME', 'SCHEMA_NAME') FROM DUAL;
to verify that the table is partitioned as expected, which it is. On our production box, however, developers aren't allowed to modify data or to run any procedures, and thus I can't use DBMS_METADATA.GET_DDL to get the DDL and, hence, to determine the INTERVAL set on the production DB. Could someone provide an idea of how to find the value used in the INTERVAL clause when the production table was built by querying system tables or views? Thanks.
Get select access to dba_part_tables (for 11gr2):
select interval from dba_part_tables where table_name = 'SOME_TABLE' and owner = 'SOME_OWNER';

Oracle Analyze Table command

Is the command Analyze table tbl compute statistics a DDL or DML? Intuitively, it seems to be neither.
When i have this command in a .sql file do i need to do :
execute immediate 'Analyze table tbl compute statistics'
I have a smiliar question about the command: GRANT DELETE, INSERT, SELECT, UPDATE ON tbl to user
UPDATE Oracle says that both grant and analyze are Data Definition Language (DDL) statements. They apparently do not make a distinction between DDL and Data Control Language (DCL).
If executing from within PL/SQL, then either execute immediate or DBMS_SQL would be needed.
Also, "Do not use the COMPUTE and ESTIMATE clauses of ANALYZE to collect optimizer statistics. " (10gR2) "For the collection of most statistics, use the DBMS_STATS
package. ... Use the ANALYZE statement (rather than DBMS_STATS)
for statistics collection not related to the cost-based
optimizer." (11g R2) Analyze table is deprecated for gathering optimizer statistics, though still usefull for other things. Use DBMS_STATS instead. (I linked to the online Oracle documentation for 10g R2. However I've been having trouble with Oracle's documenation site the last few days, with the 10g R2 documents disappearing and then reappearing.)

Resources