Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2008
    Posts
    2

    Thumbs up Unanswered: How to execute Pl/PgSql script from command line

    Hello guys,
    please could someone answer my question? how to run a plpgsql script from the command line? is possible to run like that? i hava a set of scripts to run. for example insertion for one table, updation for another table. otherwise is there any option to save those scripts in a file and through some command can i execute from the command line? if so, what should be the extension of file & what is the command to run that file. please suggest me some solution.

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    PSQL. With the -f argument to execute a script file. (Normally SQL script files are saved with a .SQL extension, but, there's no requirement for this.) Or, you can invoke PSQL to run a single command, (with the -c argument) although this will be inefficient if you have very many commands, as the executable will be loaded and unloaded for each command.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Note that the script files are simply text files. They can be created with any text editor, or you can save script you develop using the pgAdmin query tool. Or, any other query tool I'm aware of.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  4. #4
    Join Date
    Jul 2008
    Posts
    2
    thanks loquin. i'll try it & let you know if i get any doubts

Posting Permissions

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