# How to execute a simple select script using a shell script?

**URL:** <https://community.unix.com/t/how-to-execute-a-simple-select-script-using-a-shell-script/335563>\
**Category:** Linux\
**Created:** [October 17, 2013, 1:31am UTC](https://community.unix.com/t/how-to-execute-a-simple-select-script-using-a-shell-script/335563 "2013-10-17T01:31:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pamsy78](https://community.unix.com/letter_avatar/pamsy78/32/6_449c533f586939b6e5f246632a46421f.png) [@pamsy78](https://community.unix.com/u/pamsy78)\
**Post date:** [October 17, 2013, 1:31am UTC](https://community.unix.com/t/how-to-execute-a-simple-select-script-using-a-shell-script/335563/1 "2013-10-17T01:31:13Z")

</div>

Hi team,

I have two select statements and need to run them using SYSDBA user

```nohighlight
select * from temp_temp_seg_usage;

select segment_name, tablespace_name, bytes/ (1024*1024) UsedMb from 
dba_segments where segment_name='TEMP_TEMP_SEG_USAGE';

```

Need to run this using a shell script say named select.txt

Can some one help me with the code, i am really new to shell scripting.

Regards,  
Pramod

---

<div class="post-metadata">

**Author:** ![Scott](https://community.unix.com/letter_avatar/scott/32/6_449c533f586939b6e5f246632a46421f.png) [@Scott](https://community.unix.com/u/Scott)\
**Post date:** [October 17, 2013, 5:13am UTC](https://community.unix.com/t/how-to-execute-a-simple-select-script-using-a-shell-script/335563/2 "2013-10-17T05:13:04Z")

</div>

Normally, it would go something like this:

```nohighlight
sqlplus -s / as sysdba << !
set pagesize off heading off feedback off
<your select statements go here>
!

```

To run the "script":

```nohighlight
sqlplus -s / as sysdba @select.txt

```

Make sure "select.txt" exits the script.

If you need to set your Oracle environment beforehand, run this before the sqlplus:

```nohighlight
ORAENV_ASK=NO
ORACLE_SID=<your Oracle SID here>
. oraenv

```
