PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 20th, 2003, 04:30 AM
jagan_5378 jagan_5378 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: hyd
Posts: 33 jagan_5378 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 50 sec
Reputation Power: 6
command line script

hi to all
how to execute one script in command line?
in post gress sql

for example
i write some query in myfile.sql.

myfile.sql contents

select * from emp;

ok
now i want to execute this file (myfile.sql) script
from command line.
pl tell me how to execute this?

thank u

Reply With Quote
  #2  
Old December 20th, 2003, 04:08 PM
kurious's Avatar
kurious kurious is offline
Prom night: 1973
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Dec 2001
Posts: 1,152 kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 2 Days 7 h 36 m 22 sec
Reputation Power: 11
You can use psql to do this.

psql -f myfile.sql

will read the file myfile.sql and output its results to screen. If you want to save them in a file, you can do

psql -f myfile.sql >results.txt

You may need to specify the database you're querying, and your user name.

psql -f mysql.sql -d databasename -U username

If you want to format the output of your result, take a look at

this thread

Other options are available. You can see them using

psql --help

Hope this helps.

Reply With Quote
  #3  
Old December 21st, 2003, 11:51 PM
chandar chandar is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: bangalore
Posts: 132 chandar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 37 m 37 sec
Reputation Power: 6
Send a message via MSN to chandar Send a message via Yahoo to chandar Send a message via Google Talk to chandar
hi
thank u very much

bye
jagan

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > command line script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT