How to find out an Oracle DB Service Name.

Simply run the following query :

show parameter service_name;

How to export query results from Oracle SQL Developer tool

So you ran a query in Oracle SQL Developer and it returned many rows. You would like to take this data and export it to a excel , CSV,  PDF or HTML file for further processing and easier navigation. You can achieve this by following these steps:


  1. SQL Developer usually return a limited number of rows, to get all rows go to the last returned row and press Ctrl + End. This will fetch all rows.
  2. Now Select all your data by highlighting it.
  3. Right click on your selection and select Export Data and finally choose a file format.
  4. Give your file a name and location and confirm the export operation.


Kill connections to an Oracle Schema


You can kill all connections by running the code below. Just Replace SCHEMA with your schema name.

declare str varchar2(100);
begin
for SES in (select sid,serial# from v$session where username='SCHEMA'  )
loop
str := 'alter system disconnect session '|| '''' || to_char(SES.sid) ||','||to_char(SES.serial#)||'''' || ' ' || 'immediate';
execute immediate str;
end loop;
end;


To kill a single connection, first find the connection by running:

select * from v$session;

Then run:

alter system kill session 'sid,serial#';

where sid and serial# are extracted from your first query of v$session above.

How to run sqlplus


To run sqlplus you need 3 env var set. Set them as follows if they are not set already. ( you can check if they are set by doing "echo $ORACLE_SID" for example to see if your SID is set. )

export ORACLE_HOME=<your Oracle Home>
export PATH=%ORACLE_HOME%\bin;%PATH%
export ORACLE_SID=<your SID>

Then run the following at the command line to start sqlplus.
sqlplus /nolog

This starts sqlplus with no user logged in.

How to export a schema in Oracle 11g

First make sure your ORACLE_SID,  PATH and ORACLE_HOME Env. variables are set. If not set them like below :
export ORACLE_HOME=<your Oracle Home>
export PATH=%ORACLE_HOME%\bin;%PATH%
export ORACLE_SID=<your SID>

Then run the following command from the command line:

expdp system/system_password@sid schemas=Schema_Name dumpfile=Schema_Name.dmp