Need command to run sql script from sql prompt

Hi,
I am beginner in sql i need a command to run sql file from sql prompt.In notepad i have write 10 to 15 tables creation and saved as .sql i want to run this file from sql promp pls some one help.I am very great full to all users in this forum.

You can also use the 'start' command.
You may also want to look in the SQLPlus User Guide and Reference (for your release) at the set command for commands to set the number of lines per page, turn headings on or off, and so on:
http://download.oracle.com/docs/cd/E11882_01/server.112/e10823/toc.htm
HTH -- Mark D Powell --

Similar Messages

  • Running sqlplus scripts from Java code?

    hi
    I need to programmatically run sqlplus scripts from Java code on a machine that doesn't have sqlplus installed.
    Is there any Java class library available for doing this?

    The Ant approach could probably work for me, thanks for the tip.
    The setup seems rather complex however, given the simplicity of the task. I would prefer just running a Java based SQL*Plus from in a separate process or doing this via an API that would allow me to run SQL*Plus scripts (parse script, substitute variables, run statements).
    Oracle SQL Developer v1.1 appears to include an API that does exactly this.
    The ScriptParser, Substitution and SQLPLUS classes in the oracle.dbtools.raptor.scriptrunner package (oracle.sqldeveloper.jar) seem to do just what I need based on my tests.
    Can I use these classes for this purpose in my application? Is repackaging allowed?
    Does Oracle have any plans for releasing this sort of functionality separately e.g. as part of the Instant Client?

  • How to execute sql script from linux command line

    Hello everyone !
    Just short question. On my server I must install script in crontab which will eexecute some sql statements.
    How can I write command which will execute script from file without asking about password ?
    sqlplus user/pass ... and then what ?
    thanks
    dlugasx

    user10064952 wrote:
    Just short question. On my server I must install script in crontab which will eexecute some sql statements.
    How can I write command which will execute script from file without asking about password ?Crontab does not run your local shell profile - which means no valid Oracle environment for SQL*Plus to execute in.
    On newer cron versions, you can add an environment to the crontab file itself that needs to be set before executing the scheduled command.
    Whatever method - make sure you have ORACLE_HOME set, that the path includes ORACLE_HOME/bin, that ORACLE_SID is set (if not using a TNS alias) and so on.
    But I agree with Sybrand... crontab is not the best place for running SQL or PL/SQL code. That should reside in the database as named code (e.g. stored procs) and be executed via DBMS_JOB or DBMS_SCHEDULE.
    Less moving parts that way. No external dependancies. And will work on any Oracle server, irrespective of the o/s used and whether or not the relevant o/s user has batch/cron/etc privs to do the deed.

  • Running sql script from pl/sql

    Is there any standard way to run an external sql script from pl/sql
    I really appreciate any assistance.

    If you want, I did start writing a function reading and executing statements out of sql script with utl_file.
    can I issue this command in PL/SQL: EXECUTE IMMEDIATE '@filename.sql';
    the function could be extended for DDL, session setting, etc...
    Regards
    Laurent

  • Getting windows error during running the sql scripts from form 6i

    I made a little form application. The purpose of this application is to generate explain plan for a particular SQL. Some sql scripts run internally in order to populate the result on form’s screen after pressing the form’s button but I am getting windows error during running the sql scripts from form 6i.
    I am using forms 6i with patch 17 with Oracle 10G database on windows 2000 professional on same computer.
    This application runs fine with 8i.
    Please inform me where the problem is and how to overcome it.
    Zafri.

    I am using Text_IO in my form's when button press trigger , inorder to create the
    text file, then in the same when button press triger
    I am calling RMAN via host command in order to run the script which was created by text_IO.
    Below you find some of the code. I will appreciate if you solve the problem.
    when button press trigger:
    Declare
    in_file3 Text_IO.File_Type;
    linebuf3 VARCHAR2(1800);
    output11 varchar2(1000);
    BEGIN
         output11:='C:\EXPLAIN_PLUS\misc\rm_file.bat ';
    Host(output11,no_screen);
    :sql.execution_plan:= 'Working........................';
    synchronize;
    in_file3 := Text_IO.Fopen('c:\explain_plus\misc\create_table.txt', 'w');
    Text_IO.Put_Line(in_file3, linebuf3);
    Text_IO.put_line(in_file3,' ');
    Text_IO.put_line(in_file3,' run { sql "create table PLAN_TABLE (statement_id,...object_name varchar2(30),object_instance numeric,object_type varchar2(30),optimizer varchar2(255),search_columns number,id .....partition_start varchar2(255),partition_stop  varchar2(255),partition_id numeric,other long,distribution varchar2(30)) "; } ');
    Text_IO.put_line(in_file3,' ');
    Text_IO.put_line(in_file3,' ');
    Text_IO.FCLOSE(in_file3)
              Declare
    un VARCHAR2(80);
    pw VARCHAR2(80);
    cn VARCHAR2(80);
    output VARCHAR2(1000);
    output2 VARCHAR2(1000);
    dummy varchar2(40);
    in_file Text_IO.File_Type;
    linebuf VARCHAR2(1800);
    BEGIN
         Get_Connect_Info(un,pw,cn);
         /* for Plan_table Begg. Second INNER BLOCK */
         declare
              dummy2 varchar2(40);
         begin
         select table_name into dummy2 from all_tables where table_name='PLAN_TABLE';
         if dummy2 = 'PLAN_TABLE' then
         output2:='rman target/ nocatalog @C:\EXPLAIN_PLUS\MISC\TRUNC2.txt ' ;
    Host(output2,no_screen);
         end if;
         exception
         when no_data_found     then
    output2:='rman target/ nocatalog @C:\EXPLAIN_PLUS\misc\create_table.txt ';
    Host(output2,no_screen);
         end; --

  • Running  sql scripts from different directory

    Hi
    I have sql scripts in different directories as follows:
    D:\myapp\sql
    - load.sql
    - init.sql
    D:\myapp\sql\schema
    -users.sql
    -structure.sql
    D:\myapp\sql\populate\
    - data1.sql
    - data2/sql
    load.sql call all the other scripts as below:
    @init.sql
    @schema\users.sql
    @schema\structure.sql
    @populate\data1.sql
    @populate\data2.sql
    All my scripts run correctly when I run load.sql from D:\myapp\sql on comand prompt.
    I need a way to run this script from a different directory say D:\ or C:\
    I am writing a installer which will execute from a different directory.
    Right now I get a file not found error for scripts within schema an populate folder.
    Please let me know how can I make this work from a different directory.
    Thanks
    kelvin

    Hi peter. i think you cannot run files spread across different locations.
    --the method which u specified always looks to the defined path                                                                                                                                                                                                                                                                                       

  • Running a sql script from stored procedure

    Hi everyone!
    Has anybody tell me how to execute a sql script from a stored
    procedure!
    Thanks in advance!
    Sasa

    >
    Hi everyone!
    Has anybody tell me how to execute a .sql file from a stored
    procedure!
    Thanks in advance!
    Sasa Sorry, a .sql file!!

  • Calling a SQL script from the PL/SQL block.

    Hello All,
    I am using oracle 11g database.
    My requirment is as follows. I have a SQL script to alter the table. But before alter the table I need to test some condition , if the condition satisfy then I have to alter the table through the SQL script. For the checking the condition I have to use the plsql block and inside I need to call the SQL script.
    Can I call a SQL script from PL/SQL block, if yes then how?
    I am tring to use START, RUN and @ command but it is throughing error.
    Thanks
    SUN

    [PL/SQL manual|http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/functions55a.htm#77600] Ctrl-F start, finds nothing. [SQLPlus manual|http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/toc.htm] Ctrl-F start finds this. Isn't it wonderful that Oracle documents this stuff so we don't have to guess.
    Can I call a SQL script from PL/SQL block, if yes then how? No.
    You could call the stored procedure in a SQL*Plus script before the alter table and have it raise an exception if the condition is not met and have the script quit when there is an error.

  • How to call SQL script from PL/SQL block

    Hi All,
    I have a pl/sql block from which i need to call a *.sql script file.
    Please tell me that how can i do this?
    Thanks and Regards.

    > Though just for knowledge sake, would you please tell if there is a way
    to call a sql script from a pl/sql block.
    This question stems usually from a confusion about client-server and which is which in Oracle.
    SQL*Plus is a client. PL/SQL is a server side language. SQL is a server side language.
    When entering either one of these two languages in SQL*Plus (or TOAD, SQL-Developer, etc), the content is shipped to an Oracle server process, is parsed there, and is executed there.
    The Oracle server process servicing the client can accept a single SQL statement or PL/SQL block at a time.
    It cannot accept a block of SQL statements delimited with a semicolon. That is a client concept where the client will read each delimited statement and send that, one after the other (in synchronous call mode) to the Oracle server for execution.
    The Oracle server does not have a "script parser". It understands SQL. It understands PL/SQL. And that is what it expects from the client.
    Whether the client supports the SET command, the HOST command, SPOOL command, ability to run scripts, and so... have no bearing on what the server itself is capable of doing. The server does not care what feature set the client has. It is tasked with servicing the client via SQL and PL/SQL.
    It is not tasked to support or emulate client features like running SQL scripts.
    Nor confuse PL/SQL with the very limited command set of SQL*Plus. The two has nothing in common. And just as PL/SQL cannot understand C# or Delphi commands, it cannot understand SQL*Plus commands.

  • How to load SQL scripts from a text file.

    Hi, i tried several time to load a text file/SQL script with 10 different tables and data, but 10g Express doesen't allows me to do that, any one can direct me or point out to me what i should do or do i need to adopt any special method to to get this done. i am sure there must be some thing where you can upload SQL scripts from a text file (in SQL command editor!). thanks

    Hi,
    see my other answer here:
    SQL command editor doesn't take more than 1 insert command
    This seems to be a duplicate question, right? Or am I missing something?
    Regards,
    ~Dietmar.

  • Running SQLPLUS script from command prompt on SUN

    We are making a migration from VMS to SUN ( SunOS 5.10) and from 9i to 10g. We have encountered an unanticipated problem with running scripts from the command line in SUN(SQLPLUS execution from the command line). All of our packages have a naming convention such as "DM$LOAD.PKB". I know it is a strange naming convention.
    The problem is that when the package creation script is run in SQLPLUS at the command prompt SQLPLUS can not open the file.
    SQL> @dm$load.pb
    SP2-0310: unable to open file "dm$load.pb"
    SQL> host ls
    dm$load.pkb
    SQL>
    Setting the escape character does not seem to help.
    SQL> set escape '\'
    SQL>
    SQL> @dm\$load.pb
    SP2-0310: unable to open file "dm$load.pb"
    SQL>
    Unfortunately, we can not rename the scripts. This can be done from a shell script, but our Tech Services refuse to run the SQL scripts from a shell script
    Any ideas on how to get SQLPLUS to run the scripts from the SUN command line?

    I did not notice that the cut and paste was poor. It should have read
    SQL> @dm$load.pkb
    SP2-0310: unable to open file "dm$load.pkb"
    SQL> host ls
    dm$load.pkb
    Any ideas will be greatly appreciated.

  • Calling sql script from pl/sql block

    Hi
    I want to call a sql script from pl/sql block.
    like
    CREATE OR REPLACE procedure DataBaseExport(user_name in varchar2, pwd in varchar2)
    as
    begin
    execute immediate  '@ C:\Documents and Settings\umesh\emp.sql';
    end DataBaseExport;
    /

    Try something like this -
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
    import java.io.*;
    public class Host
         public static void executeCommand(String command)
         try {
                String[] finalCommand;
                   if (isWindows())
                        finalCommand = new String[4];
                        // Use the appropriate path for your windows version.
                        finalCommand[0] = "C:\\windows\\system32\\cmd.exe"; // Windows XP/2003
                        //finalCommand[0] = "C:\\winnt\\system32\\cmd.exe"; // Windows NT/2000
                        finalCommand[1] = "/y";
                        finalCommand[2] = "/c";
                        finalCommand[3] = command;
                   else
                        finalCommand = new String[3];
                        finalCommand[0] = "/bin/sh";
                        finalCommand[1] = "-c";
                        finalCommand[2] = command;
              final Process pr = Runtime.getRuntime().exec(finalCommand);
             pr.waitFor();
             new Thread(new Runnable()
                public void run()
                      BufferedReader br_in = null;
                   try
                        br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                        String buff = null;
                        while ((buff = br_in.readLine()) != null)
                                  System.out.println("Process out :" + buff);
                               try {Thread.sleep(100); } catch(Exception e) {}
                        br_in.close();
                   catch (IOException ioe)
                        System.out.println("Exception caught printing process output.");
                        ioe.printStackTrace();
                 finally
                     try {
                              br_in.close();
                          } catch (Exception ex) {}
         ).start();
         new Thread(new Runnable()
           public void run()
                BufferedReader br_err = null;
                try
                   br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
                   String buff = null;
                   while ((buff = br_err.readLine()) != null)
                        System.out.println("Process err :" + buff);
                        try
                           Thread.sleep(100);
                         } catch(Exception e) {}
                   br_err.close();
               catch (IOException ioe)
                   System.out.println("Exception caught printing process error.");
                   ioe.printStackTrace();
              finally
                  try
                          br_err.close();
                   catch (Exception ex) {}
          ).start();
         catch (Exception ex)
                  System.out.println(ex.getLocalizedMessage());
      public static boolean isWindows()
              if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
              return true;
              else
              return false;
    CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'Host.executeCommand (java.lang.String)';
    --- THE PERMISSIONS ---
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');And, finally,
    create or replace procedure call_sql_file(usr  in varchar2,
                                              pwd  in varchar2,
                                              host_str in varchar2)
    is
    begin
       host('sqlplus -s usr/pwd@host_str C:\UAX_Auto_Count.sql');
    exception
      when others then
        dbms_output.put_line(sqlerrm);
    end;Now, you can pass all the argument in order to execute that file.
    N.B.: Not Tested...
    Regards.
    Satyaki De.

  • Calling shell script from sql procedure

    Hi gurus
    Is it possible
    1)to call a shell script from sql procedure
    2)that shell script has to return one value
    3)and again sql procedure(calling shell script) has to capture the return value.
    please help me to write this script

    You may NOT have EXECUTE privilege/ permissions on the DBMS_PIPE package. Check with your DBA.
    Using DBMS_PIPE may not be that simple to implement. Just making a call to DBMS_PIPE procedure will not do anything. It will NOT trigger anything on the UNIX side.
    . You will also need to :
    1.     Write a job (ie CRON) at UNIX side which will keep read the incoming pipe for new messages, Unpack the message and get the command to be executed at the UNIX side -- There will be a lot of work involved here + DBA presence/activity is also required.
    As Justin has pointed out, try and use HOST command which is very simple or try and use Java.
    Shailender Mehta

  • How to run the SQL Script in SQL Prompt?

    Hi ExpertGroup,
    I have written one SQL Script name called "MySQLSCript.SQL". I want to know how to run the SQL Script in SQL Prompt?.
    Generally, I run SQL Script in PL/SQL Developer tool. But In this case, some SET command is not working/supporting in PL/SQL Developer Tool.
    Let me know, How to Run in SQl Prompt.
    Thanks & Regards,
    Senthil K Kumar.

    This is my SQL Script....
    SET COLSEP '|'
    SET LINESIZE 32767
    SET PAGESIZE 50000
    /* SET LINESIZE 3000
    SET PAGESIZE 50000
    SET DEFINE OFF */
    SET ECHO OFF
    SET FEEDBACK OFF
    --SET HEADING OFF
    SET TRIMSPOOL ON
    SET NEWPAGE NONE
    SET UNDERLINE OFF
    SPOOL &&EnterPath;
    SELECT * FROM &&TableName;
    SPOOL OFF
    SET FEEDBACK ON
    --SET DEFINE ON
    PROMPT Done.
    I am able to run this script in SQL Prompt....
    Its executing fine...
    But, If I am executing again it maynot asking for new set of data....
    alternativily its taking old values only.....
    how can i exeute with new set of data in the sql prompt.....

  • Executing sql scripts from url

    A nice feature of isqlplus was that we could execute a sql script stored on a
    server from a browser on a client, using dynamic. Is ther any comparable
    facility in APEX for executing a sql script from a browser?

    Hi!
    Here are some other threads to look at. Make sure to also look at the blog at the bottom of the 2nd thread. In the forum search set the date range to "all" and search on "run_cmd". You might have to look thru a few pages but there are several threads.
    How to execute sqlplus command in html_db
    Re: Returning dbms_output.putline type output to apex page
    Re: RUN A DOS BATCH FILE FROM PLSQL...
    Also go to ASKTOM (Tom Kyte) and search on "run_cmd":
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3361193268672
    This will give you several ideas!
    Let us know if you can't get it working.
    Dave Venus

Maybe you are looking for

  • Rows to Column in adf

    Dear All, How to show the rows in VO as columns in the UI table. Pls help!!! Soya

  • Folder with Question Mark when booting?

    Twice during the past 4 times booting my MacPro, I have received a folder icon with a question mark in it. I turned off the mac and restarted it and it rebooted. Why is it doing this? Thanks.

  • Photoshop Quick Selection Tool

    Okay.... I am sorry, this is really dumb, but I have wasted enough time on this.  On one computer when I select my selection tool I have a circle with a + inside or - whichever I choose to select or deselect an object.  BUT, on my other computer I ha

  • Program to send Workflow Approval Notifications to Outlook (RSWUWFMLEC)

    Hi, We recently upgraded from SRM 4.0 to 7.0. We used RSWUWFMLEC to extract approval work items and send email notifications to Outlook. Can we use same RSWUWFMLEC or is there a different program/process for this in SRM 7.0. For some reason RSWUWFMLE

  • Mini server second NIC issues

    So i got a apple usb>ethernet conveter and went ahead and setup a PPPOE connection to my modem over the usb>ethernet connection. Snowleopard sever sees this and can access the internet fine. The internal NIC is still connected to the rest of the netw