Jago6060 Posted June 24, 2009 Share Posted June 24, 2009 Ok so as of right now, I've only been working with PostgreSQL for 15 minutes, so please bare with me. Here's what I've done so far... logged in with the command psql -U [i]username[/i] Which prompts for a password. I entered the password which then brings me to the prompt where I select my database to use. Now, I know SQL, but I'm having trouble using the SQL commands in PSQL. I tried two different ways... projop-#SELECT * FROM users And... projop-#\! SELECT * FROM users The first returns nothing and the second says... sh: SELECT: command not found My Goal: To be able to view records in a table, and alter them. Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/163512-need-help-with-postgresql-command-line/ Share on other sites More sharing options...
btherl Posted June 25, 2009 Share Posted June 25, 2009 Is it possible that the users table is empty? If it is you should see something like this: db=> select * from foo; -- (0 rows) You can also try selects that don't involve any tables, like this: db=> select now(); now ------------------------------- 2009-06-25 11:45:49.429334+10 (1 row) If the table is empty, you need to insert some data into it. Quote Link to comment https://forums.phpfreaks.com/topic/163512-need-help-with-postgresql-command-line/#findComment-863069 Share on other sites More sharing options...
Jago6060 Posted June 26, 2009 Author Share Posted June 26, 2009 Thanks for the help! Its working now. I'm not sure what the issue was before. I do have another question though. Can records be altered via SQL statements in a PostgreSQL database? Quote Link to comment https://forums.phpfreaks.com/topic/163512-need-help-with-postgresql-command-line/#findComment-864146 Share on other sites More sharing options...
btherl Posted June 28, 2009 Share Posted June 28, 2009 Yes they can. The command which alters records is "update". For example UPDATE foo SET name = 'btherl' WHERE userid = 10 That will change all rows in table foo which have column userid equal to 10, setting column name to 'btherl' in each one. If there is only one row with userid 10 then only 1 column will change. If there's 0 rows matching, 0 rows are changed and it isn't an error. If there's many rows, all are changed. PS: These are all generic SQL commands. If you find a MySQL tutorial, which is easier to find than a postgresql tutorial, you can learn SQL from there and then use most of it in Postgresql. Quote Link to comment https://forums.phpfreaks.com/topic/163512-need-help-with-postgresql-command-line/#findComment-864891 Share on other sites More sharing options...
artacus Posted June 28, 2009 Share Posted June 28, 2009 If you're just getting started, you should probably use a GUI. PgAdmin should have come with your postgres install. I haven't used it in a while but phpPgAdmin is pretty nice. Quote Link to comment https://forums.phpfreaks.com/topic/163512-need-help-with-postgresql-command-line/#findComment-864938 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.