Posts

Showing posts from July, 2013

Finding out Last DML Activity on a Table

Image
create a function for the DML logging   create or replace function scn_to_timestamp_safe(p integer) return timestamp is   e_too_old_scn exception;   pragma exception_init(e_too_old_scn,-8181); begin   return      case        when p is not null then scn_to_timestamp(p)        else null      end; exception   when e_too_old_scn then     return null; end; /    now querying the last DML (insert,update,delete) for table and this cant say if  there was any select query run or not.    select   t.owner||'.'||t.table_name ,extractvalue( dbms_xmlgen.getXMLtype(q'[select nvl(scn_to_timestamp_safe (max(ora_rowscn)),timestamp'0001-01-01 00:00:00') t  from "]'||t.owner||'"."'||t.table_name||'"')                ,'/ROWSET/ROW/T'      ...

Find all tables without primarykey in Database

As a  DBA we need to make sure that all the tables in your database are have their uniquesness  so that the rows are not duplicate and we avoid the redundant data in our databases.  below is the simple sql that can give you list of tables that don't have any primary key: SELECT OWNER, table_name FROM all_tables MINUS SELECT OWNER,table_name FROM all_constraints WHERE constraint_type = 'P' AND OWNER NOT IN ('sys','system'); you list out all the schemas you want to avoid looking for.

Easiest way to switch between schemas just with a click of button using sqqldeveloper

Image
Easiest way to switch between schemas just with a click of button in sqldeveloper 3.2 or lower versions.This doesnt work with sqldev 4 or higher General :   The Schema Select extension for Oracle SQL Developer provides a convenient drop-down list which lets you choose the current schema in a sql worksheet. It also allows you to specify a default schema for newly opened worksheets. Features: Default schema can be specified in connection name Current schema can be selected from a drop-down list Works in Oracle SQL Developer versions 3.0, 2.1 and 1.5 Support for Oracle, MySQL and MS Sqlserver databases Easily extendable to support other databases This extension was created using Oracle JDeveloper and the IDE Extension SDK. download it from : http://javaforge.com/project/schemasel direct download   >>> http://javaforge.com/displayDocument/oracle.sqldeveloper.thirdparty.schemaselect.jar?doc_id=80273

Easiest way to switch between schemas just with a click of button using sqqldeveloper

Image
Easiest way to switch between schemas just with a click of button in sqldeveloper 3.2 or lower versions.This doesnt work with sqldev 4 or higher General :   The Schema Select extension for Oracle SQL Developer provides a convenient drop-down list which lets you choose the current schema in a sql worksheet. It also allows you to specify a default schema for newly opened worksheets. Features: Default schema can be specified in connection name Current schema can be selected from a drop-down list Works in Oracle SQL Developer versions 3.0, 2.1 and 1.5 Support for Oracle, MySQL and MS Sqlserver databases Easily extendable to support other databases This extension was created using Oracle JDeveloper and the IDE Extension SDK. download it from : http://javaforge.com/project/schemasel direct download   >>> http://javaforge.com/displayDocument/oracle.sqldeveloper.thirdparty.schemaselect.jar?doc_id=80273