Posts

Showing posts from June, 2020

Chnage Oracle DB name

When was the last time you had to change the name of a database? Long time ago, changing the database name was a big thing. Nowadays not so much anymore! In the case of a database refresh, RMAN takes care of that for you, during the cloning process. But, I am not referring to changing database name for a refresh purpose. What I am referring to in my question today, is actually changing the name of a database, let’s say from HRPROD to HRPRD, on purpose, and not through refresh or clone. Now you might be asking me, why would you do that? I’ll let you know, why I did it, just keep on reading! I was upgrading a database to 19c. The method I was using was to create an empty 19c database, export the required schemas from the older version, and import into the newly created database. The only issue was that the new database and the old one were on the same server, and having a different database name was out of the question. This is why, I ended up changing the database name, as the last step...

Script to display the SQL text for a specific SQL_ID

--> Purpose:    Script to display the SQL text  for a specific SQL_ID. -->             It returns the SQL_TEXT. --> Parameters: sql_id --> To Run:     @sqltext.sql sql_id --> Example:    @sqltext.sql 27b3qfm5x89xn --> --> Copyright 2020@The Ultimate SQL Tuning Formula set echo off set define '&' set verify off define _sql_id=&1 set verify off set feedback off set linesize 200 set heading on set termout on col sqltext format a100 word_wrapped select  sql_text as sqltext from gv$sqltext where sql_id = '&_sql_id' order by piece; **************************************************************************************** --> Purpose:    Script to display the SQL text  for a specific SQL_ID. -->             It returns the SQL_TEXT. --> Caution:  ...

Move Oracle Datafiles ONLINE in 12c

Do you remember the old days when we had to move datafiles, and this process had to be completed offline, it could not be done while users were accessing the datafile? Gone are those days now! In 12c things changed, and since, datafiles can be moved online, while the users are accessing the content of the datafile. Why would you want to move a datafile? 1) you need to place the datafile to a different location. By example: /u01/oradata/TSTDB/user_data01.dbf to /u02/oradata/TSTDB/user_data01.dbf 2) you need to rename the file, as the initial name is not correct, and you want to make the correction. By example /u01/oradata/TSTDB/user_data)01.dbf to u01/oradata/TSTDB/user_data01.dbf 3) you are moving the file to ASM 4) another reason you might have Anyhow, the good news is that you can perform this operation online. In order to accomplish this task, we need to use the ALTER DATABASE MOVE DATAFILE statement. You can refer to the datafile either by name, or by datafile number. To get the fi...