sed -i "s/oldstring/newstring/g"
For example
sed -i "s/11204/12102/g" /etc/oratab
Minimalistic Oracle contains a collection of practical examples from my encounters with Oracle technologies. When relevant, I also write about other technologies, like Linux or PostgreSQL. Many of the posts starts with "how to" since they derive directly from my own personal experience. My goal is to provide simple examples, so that they can be easily adapted to other situations.
sed -i "s/oldstring/newstring/g"
sed -i "s/11204/12102/g" /etc/oratab
select comp_id,comp_name, version,status from dba_registry; COMP_ID COMP_NAME VERSION STATUS -------------------- ---------------------------------------- ------------------------------ -------------------- XDB Oracle XML Database 12.1.0.2.0 VALID XML Oracle XDK 12.1.0.2.0 VALID
set lines 200 col comp_name format a50 col version format a20 col status format a20 col parameter format a30 col value format a30 select comp_id, comp_name,version,status from dba_registry; COMP_ID COMP_NAME VERSION STATUS ------------------------------ -------------------------------------------------- -------------------- -------------------- RAC Oracle Real Application Clusters 11.2.0.4.0 INVALID 16 rows selected.
select value from v$option where parameter = 'Real Application Clusters'; VALUE ------ FALSE
exec dbms_registry.removed('RAC');
COMP_ID COMP_NAME VERSION STATUS ------------------------------ -------------------------------------------------- -------------------- -------------------- RAC Oracle Real Application Clusters 11.2.0.4.0 REMOVED 16 rows selected.
SQL> @?/olap/admin/olap.sql SYSAUX TEMP; SQL> execute cwm2_olap_metadata_refresh.mr_refresh; BEGIN cwm2_olap_metadata_refresh.mr_refresh; END; * ERROR at line 1: ORA-04063: package body "OLAPSYS.CWM2_OLAP_METADATA_REFRESH" has errors ORA-06508: PL/SQL: could not find program unit being called: "OLAPSYS.CWM2_OLAP_METADATA_REFRESH" ORA-06512: at line 1
$ sqlplus '/ as sysdba' SQL> drop user OLAPSYS cascade SQL> @?/olap/admin/olap.sql SYSAUX TEMP; SQL> @?/rdbms/admin/utlrp.sql
char(int)to concatenate a line feed into your string. Integer represents the decimal value of the character you'd like to send to the database.
set trimspool on set lines 200 set pages 0 set heading off set verify off set echo off set feedback off spool rowcount.sql select 'spool rowcount.out' from dual; select 'prompt rowcount for ' || owner || '.' || table_name || chr(10)|| 'select count(*) from ' || owner || '.' || table_name || ';' from dba_tables where owner='SCOTT'; select 'exit' from dual; exit
SYS@fsprod SQL> select chr(10) from dual; C -
spool rowcount.out prompt rowcount for SCOTT.EMP select count(*) from SCOTT.EMP; prompt rowcount for SCOTT.DEPT select count(*) from SCOTT.DEPT; prompt rowcount for SCOTT.BONUS select count(*) from SCOTT.BONUS; . . . exit
select * from v$option where PARAMETER = 'Data Mining'; PARAMETER VALUE ------------ ------------ Data Mining FALSE
chopt enable dm Writing to /u01/oracle/product/11204/install/enable_dm.log... /usr/bin/make -f /u01/oracle/product/11204/rdbms/lib/ins_rdbms.mk dm_on ORACLE_HOME=/u01/oracle/product/11204 /usr/bin/make -f /u01/oracle/product/11204/rdbms/lib/ins_rdbms.mk ioracle ORACLE_HOME=/u01/oracle/product/11204
sqlplus / as sysdba SQL>spool enable_dm.log SQL>@catodm.sql SQL>@dbmsodm.sql SQL>@prvtodm.plb6. Confirm that Data Mining is indeed installed:
select * from v$option where PARAMETER = 'Data Mining'; PARAMETER VALUE ------------ ------------ Data Mining TRUE