-2

I was just going through an online tutorial on psql and came across the following command:

psql -U user -d postgres -f ~/Desktop/pgrouting-workshop/data/sampledata_notopo.sql

I am just wondering what all those parameters -d and -f, I am new to Ubuntu and don't even know what keyword to search for, So that i could get the documentation for those flags.

Can somebody break it down for me?

guntbert
  • 12,914
  • 37
  • 45
  • 86
  • Where did you install psql from as it does not appear to have a `man` page? –  Sep 01 '15 at 20:26

1 Answers1

1

As another user pointed out, in Ubuntu (and other Linux distributions), you can typically find man (manual) pages with the man command, e.g.:

    man psql 

which would give you a "man page" on how to use the "psql" command. Alternatively, you can also try the info command, e.g.:

    info man 

which would give you information on the "man" command.

For a brief overview of man vs. info, look here.

The psql command as you are using it can be broken down:

    psql 

(the command itself)

    -U user 

(connect as the user named "user")

    -d postgres 

(to the database named postgres)

    -f ...

(use the filename located at ... as the source for the queries, as opposed to interactively ).

In brief, Linux commands generally take the form:

    command -option(s) arguments . 
marshki
  • 326
  • 1
  • 7
  • one question ! , i am still not getting the use of the `-f` flag ! why is it being used ? – Alexander Solonik Sep 02 '15 at 09:59
  • Per the man page for the psql command: "Use the file filename as the source of commands instead of reading commands interactively". In your circumstance, you are specifying the: `-f sampledata_notopo.sql` file. – marshki Sep 02 '15 at 12:58