Archive for March, 2010

Show date time tables were created

Tuesday, March 30th, 2010

To see when tables (or other objects) were created, first change your date format to display time:

alter session set nls_date_format='Dy DD-Mon-YYYY HH24:MI:SS';

Then in Oracle SQL Developer, right click on the table or object in question, select ‘open‘, and look at the ‘details‘ tab.

Or alternatively still in SQL, look at the created column:

select object_name, created from user_objects order by 2;

That is for objects owned by you. For objects owned by others:

select object_name, created from all_objects order by 2;

Note that the column ‘last_ddl_time’ is not as useful as it sounds, since even operations like GRANTs on the table update the ‘last_ddl_time’.

PL/SQL to count from all tables in a schema

Friday, March 12th, 2010

Replace SYSTEM with the name of the schema you are interested in:

set serverout on size 999999
declare
  cnt number ;
begin
  for c1 in (select owner, table_name from all_tables where owner = 'SYSTEM')
  loop
    execute immediate 'select count(1) from '||c1.owner||'.'||c1.table_name into cnt ;
    dbms_output.put_line(c1.table_name||','||cnt) ;
  end loop ;
end ;
/

Fix for Oracle XE 1608: unable to create InstallDriver instance, return code -2147221164

Monday, March 8th, 2010

I got this annoying error when attempting to install Oracle XE:

1608: unable to create InstallDriver instance, return code -2147221164

The fix for this on my PC was:

  • Identify your TEMP folder – choose start -> run -> type “cmd”, then type “set temp” in the command window.
  • Navigate to this folder in windows. It may well be a hidden folder , so  select tools  -> folder options -> view -> show hidden files and folders.
  • Attempt to install OracleXE again – but this time leave the “1608: unable to create InstallDriver instance, return code -2147221164” error dialog box visible, do not close it by clicking ok. Closing the dialog box will delete the TEMP files which we need for the next step.
  • A new folder will have been created under the TEMP folder (press F5 to refresh if necessary). Copy this new folder and all its files to a new location.
  • Now it is safe to close the “1608: unable to create InstallDriver instance, return code -2147221164” error dialog box by clicking ok.
  • Locate file ISScript11.Msi in the newly copied folder.
  • Right click on file ISScript11.Msi and select “Uninstall”
  • Right click on file ISScript11.Msi and select “Install”
  • Now attempt to install OracleXE again – for me it now ran through to completion.

Automatic gather stats job

Friday, March 5th, 2010

check it is on with:

select state, last_start_date from dba_scheduler_jobs where job_name = 'GATHER_STATS_JOB' ;

Switch it on and off with:

exec dbms_scheduler.disable('GATHER_STATS_JOB')
exec dbms_scheduler.enable('GATHER_STATS_JOB')