sqlplus

How can I kill all sessions connecting to my oracle database?

走远了吗. 提交于 2019-11-28 16:42:52
I need to quickly (and forcibly) kill off all external sessions connecting to my oracle database without the supervision of and administrator. I don't want to just lock the database and let the users quit gracefully. How would I script this? BIBD This answer is heavily influenced by a conversation here: http://www.tek-tips.com/viewthread.cfm?qid=1395151&page=3 ALTER SYSTEM ENABLE RESTRICTED SESSION; begin for x in ( select Sid, Serial#, machine, program from v$session where machine <> 'MyDatabaseServerName' ) loop execute immediate 'Alter System Kill Session '''|| x.Sid || ',' || x.Serial# ||

Oracle Shutdown error ORA-01033

拟墨画扇 提交于 2019-11-28 14:25:02
I had installed Oracle 11g on windows 07,everything was working fine.But today it is giving me an error saaying ORA-01033: ORACLE initialization or shutdown in progress . I followed the steps mentioned in the different communities but unable to solve the error. After connecting as sqlplus sys/sys as sysdba . and executing below statement,i got following error. How to solve this error? SQL> recover database; ORA-00283: recovery session canceled due to errors ORA-01110: data file 9: 'C:\APP\MKHATAL\ORADATA\ORCL\VELODBDATA.DBF' ORA-01157: cannot identify/lock data file 9 - see DBWR trace file ORA

How to create a menu in SQLPlus or PL/SQL

◇◆丶佛笑我妖孽 提交于 2019-11-28 14:00:32
I have several scripts that I would like to start from a menu presented to the SQLPlus user. Something like: Please make a selection: 1: Do script a 2: Do script b 3: Do script c I just need a point in the right direction, not a quick answer. Here is a SQL Plus script to do that: prompt Please make a selection: prompt 1: Do script a prompt 2: Do script b prompt 3: Do script c accept selection prompt "Enter option 1-3: " set term off column script new_value v_script select case '&selection.' when '1' then 'script_a' when '2' then 'script_b' when '3' then 'script_c' else 'menu' end as script

Sqlplus login error when using bash variables: SP2-0306: Invalid option

断了今生、忘了曾经 提交于 2019-11-28 13:50:55
I have a bash script that connects to an oracle 10g database. In a first step it takes some variables from a "config" file with the following command . /path/to/my/configfile.ini In the config file there are some variables: export USRID=myUser export USRID_PASS=myPassword export USR_PASS="$USRID/$USRID_PASS@myDatabase" Then it actually connects through sqlplus using the command: sqlplus -s $usr_pass Terrible Security and Design issues aside (this script has been around for 5 years). This is actually doing its job in one of our UNIX servers, but not in another. When I run the script with bash

Duplicate columns with inner Join

℡╲_俬逩灬. 提交于 2019-11-28 12:07:22
SELECT dealing_record.* ,shares.* ,transaction_type.* FROM shares INNER JOIN shares ON shares.share_ID = dealing_record.share_id INNER JOIN transaction_type ON transaction_type.transaction_type_id = dealing_record.transaction_type_id; The above SQL code produces the desired output but with a couple of duplicate columns. Also, with incomplete display of the column headers. When I change the linesize 100 the headers shows but data displayed overlaps I have checked through similar questions but I don't seem to get how to solve this. You have duplicate columns, because, you're asking to the SQL

How do you pass an argument to a PL/SQL block within a sql file called using START in sqlplus?

ε祈祈猫儿з 提交于 2019-11-28 12:01:29
问题 I have a bash script running several sql files via sqlplus: sqlplus $connectioninfo << end start file1.sql start file2.sql start file3.sql $variable quit end file3 has some PL/SQL: BEGIN DBMS_OUTPUT.PUT_LINE(&1); END; / But it just prints the literal "&1" instead of the value of $variable . I have also tried the following in file3: DEFINE var_a = &1; BEGIN DBMS_OUTPUT.PUT_LINE(var_a); END; / and also the following: DECLARE var_b VARCHAR2(64) := &1; BEGIN DBMS_OUTPUT.PUT_LINE(var_b); END; /

Oracle SqlPlus - saving output in a file but don't show on screen

末鹿安然 提交于 2019-11-28 10:40:34
Using SqlPlus for Oracle, how do I save the output of a query in a file but not show it on the terminal/prompt. a_horse_with_no_name Right from the SQL*Plus manual http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch8.htm#sthref1597 SET TERMOUT SET TERMOUT OFF suppresses the display so that you can spool output from a script without seeing it on the screen. If both spooling to file and writing to terminal are not required, use SET TERMOUT OFF in >SQL scripts to disable terminal output. SET TERMOUT is not supported in iSQL*Plus Mohammad Try this: SET TERMOUT OFF; spool M:\Documents

Simple Oracle query: literal does not match format string

落爺英雄遲暮 提交于 2019-11-28 10:37:35
问题 I want to execute a simple function in Oracle. The signature is defined as follows: CREATE OR REPLACE FUNCTION NewCaseListForValidation ( p_fromDate in DATE, p_toDate in DATE, p_rowCount in INT ) RETURN SYS_REFCURSOR IS return_value SYS_REFCURSOR; ... I should be able to execute it with: var rc refcursor exec :rc := newcaselistforvalidation('2010-01-01','2011-01-01',100); print :rc But when typing "newcaselistforvalidation('2010-01-01','2011-01-01',100)", I get: ERROR at line 1: ORA-01861:

How do I capture a SQLPlus exit code within a shell script?

做~自己de王妃 提交于 2019-11-28 10:13:07
I have a KornShell (ksh) script that logins into SQL*Plus and executing a script. Within the shell script I would like to capture the status code of the SQL statement that was executed. Currently there is an error with SQL and I am unable to capture it by checking $?. How would I capture the success or error code from the sql statement and pass it to the shell script. Snippet of ksh script: sqlplus $JDBC_FBUID_U/$JDBC_FBPWD_U@$JDBC_FBDB @${FBC_HOME}/FBCS003.sql ${outputfile} if [ $? != 0 ] then msg_txt="The execution of Sql script /tmp/FBCS003.sql failed. Please investigate." echo ${msg_txt}

SQLplus decode to execute scripts

大憨熊 提交于 2019-11-28 09:27:41
问题 I am writing a script to be run in sqlplus 11. I have a user defined variable called compression. If this is true then I want to run the script CreateTablesCompression, otherwise run. I have the following: decode(compression,'true',@@CreateTablesCompression,@@CreateTables); However,when I run this I am thrown the error: unknown command beginning "decode... Am I missing something here, I can't see why SQLPlus wouldn't recognise decode? 回答1: Decode is not a SQL*PLUS command, you cannot use it