0

I'm looking for command, which are helpful for seeing what we have in our database tables. Any hints?

lukaszkups
  • 5,790
  • 9
  • 47
  • 85

1 Answers1

1

a hint: if it's a SQL database you execute SELECT * FROM tablename if you want to see what's in a table. But the know how you execute that command from a commandline prompt we need to know which database you are using.

UPDATE: I don't really know postgresql (and don't have it installed). But I THINK you would use something like: psql -u -c "SELECT * FROM tablename" dbname

Niclas Nilsson
  • 5,691
  • 3
  • 30
  • 43
  • 1
    You could check the psql manual (just google it) that would help you if thec command are not working. – Niclas Nilsson Jan 03 '12 at 13:38
  • yeah, I've got it now:`psql --u username --command "SELECT * FROM tablename" --dbname databasename` thanks for tips! – lukaszkups Jan 03 '12 at 15:09
  • ok, I've got a list of records - but I have to push PgDown to go down and see more records - is there any key shortcut to jump to the list end automatically? – lukaszkups Jan 03 '12 at 17:03
  • 1
    I suppose psql sends the output to a pager named "less", in that case you write a `'` and then a `$`. That will take you to the end. To go to the beginning you could press `'` and then `^` (see less manual http://unixhelp.ed.ac.uk/CGI/man-cgi?less ). Another way is to execute `psql -u username --command "SELECT * from tablename --dbname databasename |tail -n 100"`. That will only show the last 100 lines. Change 100 to something else if you want to. – Niclas Nilsson Jan 03 '12 at 17:27
  • Oh. I googled "psql less". It seems like it's not "less" that psql use. If my suggestions don't work. Look att this: http://stackoverflow.com/questions/1982453/psql-8-3-client-query-results-display – Niclas Nilsson Jan 03 '12 at 17:29
  • To be more clear. If my suggestions don't work you can use the instructions in the link to configure psql to the one of the following things: **(a)** Turn of the pager and pipe it thru tail as I suggested above. **(b)** change to the pager to less and use the shortcuts I described. **or** You could of course See psql manual to find out which shortcuts that are used in their pager (if it differs from less) – Niclas Nilsson Jan 03 '12 at 17:39
  • I really spam this thread. But have you tried the `end`-button? – Niclas Nilsson Jan 03 '12 at 17:46