SQL commands from SHELL prompt
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: SQL commands from SHELL prompt

  1. #1
    Join Date
    Nov 2000
    Posts
    101

    SQL commands from SHELL prompt

    Hi Friends,

    Is it possible to execute SQL or PL/SQL commands from Unix shell prompt. For example, I want to execute a CREATE COMMAND from "$" prompt.

    eg.
    $ sqlplus SCOTT/TIGER CREATE TABLE t1(I INT)


    Thanks
    gandhi

  2. #2
    Join Date
    Apr 2001
    Location
    Bangalore, India
    Posts
    727
    Code:
    sqlplus -s /nolog "<<"ENDSQL
    connect connectstring
    @script1.sql   or put your SQL script here.
    EXIT;
    ENDSQL

    Why don't you search in the net?

    Note: Please remove the "" from "<<"ENDSQL.
    Last edited by Thomasps; 12-28-2003 at 11:30 PM.
    Thomas Saviour(royxavier@yahoo.com)
    Technical Lead (Databases)
    Thomson Reuters (Markets)

    http://ora600tom.wordpress.com/

  3. #3
    Join Date
    Jun 2001
    Location
    Helsinki. Finland
    Posts
    3,938

    Re: SQL commands from SHELL prompt

    Originally posted by gandhi
    Hi Friends,

    Is it possible to execute SQL or PL/SQL commands from Unix shell prompt. For example, I want to execute a CREATE COMMAND from "$" prompt.

    eg.
    $ sqlplus SCOTT/TIGER CREATE TABLE t1(I INT)


    Thanks
    gandhi
    I am trying to execute OS commands through PL/SQL, you are trying to execute Oracle command on OS level :-) What a world...
    Oracle Certified Master
    Oracle Certified Professional 6i,8i,9i,10g,11g
    email: ocp_9i@yahoo.com

  4. #4
    Join Date
    Sep 2003
    Location
    Bangalore
    Posts
    36

    Post U can run sql

    Hi,
    The previous explanation is correct.
    $sqlplus /nolog < now u can write all the sql command after giving the connect string.
    to end your session.
    you need to give !END
    once again.

    This is more helpful in making shell scripts which interact with oracle.

    eg.
    sqlplus /nolog < alter system switch logfile
    <
    I hope this helps

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width