Question : sql script to drop all tables from the user

My following script does not runit give an error like below:
test-omf-01> ./auto_del_lim_cpsstage.sh
ksh: ./auto_del_lim_cpsstage.sh: cannot execute

The script is as follow:
#!/usr/bin/ksh

. /opt/users/oracle/.profile_stage
$ORACLE_HOME/bin/sqlplus /nolog <connect lim/lim@stage
set heading off
set feedback off
set pause off
set pagesize 0
set linesize 132
prompt
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET HEADING OFF
SET MARKUP HTML OFF
SET ESCAPE \
SPOOL /opt/users/oracle/admin/bin/DELETEME.SQL
select 'drop table ', table_name, 'cascade constraints \;' from user_tables;
SPOOL OFF


thanks, for assisting .

Answer : sql script to drop all tables from the user

Your script is almost there

---------------------START OF SCRIPT --------------
#!/usr/bin/ksh

. /opt/users/oracle/.profile_stage
$ORACLE_HOME/bin/sqlplus /nolog <connect lim/lim@stage
set heading off
set feedback off
set pause off
set pagesize 0
set linesize 132
prompt
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET HEADING OFF
SET MARKUP HTML OFF
SET ESCAPE \
SPOOL /opt/users/oracle/admin/bin/DELETEME.SQL
select 'drop table '||table_name||' cascade constraints ;' from user_tables;
SPOOL OFF

EOSSPLUS

-------------------------------END OF SCRIPT------------

If you want to run the drop table script automatically at the end then add the line
@/opt/users/oracle/admin/bin/DELETEEME.SQL
after spool off

Once you have saved the file. Give it execute permissions using the command
chmod +x auto_del_lim_cpsstage.sh

Then you can run it.

HTH
Vishal
Random Solutions  
 
programming4us programming4us