I wanted to install Oracle software on a RH8.5 Linux server:
This is the error I received:cat /etc/redhat-releaseRed Hat Enterprise Linux release 8.5 (Ootpa)
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.
This is the error I received:cat /etc/redhat-releaseRed Hat Enterprise Linux release 8.5 (Ootpa)
export CV_ASSUME_DISTID=OEL7.8Execute the installer again and you will see a different screen:
./runInstaller
select col.table_schema, col.table_name, col.ordinal_position as column_id, col.column_name, col.data_type from information_schema.columns col join information_schema.tables tab on tab.table_schema = col.table_schema and tab.table_name = col.table_name and tab.table_type = 'BASE TABLE' where col.table_schema in ('myschema') and col.data_type IN ( 'json','jsonb' ) order by col.table_schema, col.table_name, col.ordinal_position;Execution in psql directly on server like this:
psql mydb -f find_cols.sql
sed -i '20s/^/SET search_path to sales,public;\n/' myfile.txt
sed -i '7s/^/\\timing on\n/' myfile.txt
sed -i 's/public\.//g' mylargetextfile.txtNotice the forward slash in front of the puncuation mark. It tells sed to interpret it literally, not as a special character used in regular expressions. Source: Stackoverflow
connect / as sysdba create or replace view my_sessions as select username,sid,serial#,osuser,status,program,machine from v$session where username=SYS_CONTEXT('userenv','CURRENT_SCHEMA');Create a public synonym, and grant select to public:
create public synonym my_sessions for my_sessions; grant select on my_sessions to public;To get the procedure to compile in the SYSTEM schema, it is required to grant the "alter system" privilege directly to the user - having the same privilege through a role won't do.
grant alter system to system; grant select on v_$session to system;Log in as system, and create the procedure:
CREATE OR REPLACE PROCEDURE KILL_SESSION(PN_SID NUMBER,PN_SERIAL NUMBER) AUTHID DEFINER AS LV_USER VARCHAR2(30); EXE_USER VARCHAR2(30); BEGIN SELECT S.USERNAME INTO LV_USER FROM V$SESSION S, USER_USERS U WHERE S.SID = PN_SID AND S.SERIAL# = PN_SERIAL AND S.USERNAME = S.USERNAME; SELECT USERNAME INTO EXE_USER FROM V$SESSION WHERE AUDSID=SYS_CONTEXT('userenv','SESSIONID'); IF EXE_USER = LV_USER THEN EXECUTE IMMEDIATE 'alter system kill session '''||PN_SID||','||PN_SERIAL||''''; dbms_output.put_line('Session ' || PN_SID || ',' || PN_SERIAL || ' killed.'); ELSE RAISE_APPLICATION_ERROR(-20000,'Only your own sessions may be killed.'); END IF; END; /Create a synonym for the procedure and give everyone execute privileges on it:
CREATE PUBLIC SYNONYM KILL_SESSION FOR KILL_SESSION; GRANT EXECUTE ON KILL_SESSION TO PUBLIC;Now the users have a way to check their own sessions, and to terminate them if they chose to do so:
connect scott select * from my_session; USERNAME SID SERIAL# OSUSER STATUS PROGRAM MACHINE -------------------- ---------- ---------- -------------------- -------------------- ------------------------------------------------ ---------------------------------------------------------------- SCOTT 1152 9510 oracle INACTIVE sqlplus@myserver.mydomain.com (TNS V1- myserver.mydomain.com SCOTT 1726 31531 oracle ACTIVE sqlplus@myserver.mydomain.com (TNS V1- myserver.mydomain.comKill a session:
scott@mydb>SQL>exec kill_session(1152,9510);Afterwards, the view will change to show session 1152 to be in status KILLED:
USERNAME SID SERIAL# OSUSER STATUS PROGRAM MACHINE -------------------- ---------- ---------- -------------------- -------------------- ------------------------------------------------ ---------------------------------------------------------------- SCOTT 1152 9510 oracle KILLED sqlplus@myserver.mydomain.com (TNS V1- myserver.mydomain.com SCOTT 1726 31531 oracle ACTIVE sqlplus@myserver.mydomain.com (TNS V1- myserver.mydomain.com
cd /home/oracleFind the path to the file you are interested in:
tar -tvf oracle.tar | grep oraInst.loc -rw-rw---- oracle/dba 55 2018-01-25 15:02 ./oraInventory/oraInst.locExtract the tar file using the path displayed above:
tar xvf /u01/data/oracle.tar ./oraInventory/oraInst.loc
INSERT INTO sales.sales_history SELECT * from sales.sales_history_p201801 ON CONFLICT ON CONSTRAINT uc_sh1 DO NOTHING;Comes in as a handy way of transfering rows from an old table to a partially populated new table. Duplicate rows will simply be ignored.