psql select not working
PSQL Select not working – or other simple commands not working
Working with command line postgres tool psql and having an issue?
Why doesn’t the psql command show the simple select query?
PSQL select not working is a problem that can happen in either of the following scenarios:
- Are you on the right database?
Chances are you might not be on the right database at all and the relation you are trying to find might not be there at all:Check if you are on the right database.
Run the command
\lto see the available databases.How to connect to the postgres database from the list?
Use the command
Let’s say the database name is inventory then:
\c inventorywill connect you to the right database
- Does the table exist?
You might find this funny, but you might be surprised when you realize you are querying the wrong table or misspelled table name and get psql select not working or other related error.
How do I list and see all the postgres tables:Use the
\dto list all the tables in the current database. Like wise, you can also use
\dtas well. It will hide some of the internal tables like sequence and show you other significant tables.
So do the
\dand check if you have the table listed, or check the spelling is right.
It could be the reason of the psql select not working problem solution.
- Are you using the right schema?
Here is the last place to check for the psql command not working problem. The schema unless you define it, could be by default a public schema.
When you issue the
\dtcommand you will see the first column to be schema.That is, you might want to try your query along with schema to make sure the right schema is used. Lets say you are issuing
SELECT * From inventory.
Now, use the right schema, lets use public, it will be
SELECT * FROM public.inventory. Again, you can find the schema from the table listing command.
- Time to restart? Yup, caching and other issues might be tampering the psql and lead to the psql select not working issue. Just close the session and reopen and give it a shot.
For more, checkout this link.
Apache not executing PHP code – just renders the as it is
Process Commands in Linux
Bash directories coloring lost in unix when using ls