'In psql, why do some commands have no effect?

Sometimes my commands in psql seem to be having no effect. Any idea why?

The below is the list of all tables in the database library_development:

library_development=> \d

               List of relations
 Schema |       Name        | Type  |  Owner
--------+-------------------+-------+----------
 public | Pavan             | table | postgres
 public | schema_migrations | table | sai
(2 rows)

After this I dropped the table Pavan using:

library_development-> drop table Pavan

But the Table isn't dropped and its shows as shown:

library_development=> \d
               List of relations
 Schema |       Name        | Type  |  Owner
--------+-------------------+-------+----------
 public | Pavan             | table | postgres
 public | schema_migrations | table | sai
(2 rows)

Also:

  1. I am using PostgreSQL in Windows. Is there any command to clear the console (Like cl scr present in Oracle)?

  2. Is there any concept of a "commit" I need to perform in Postgresql when working with DML scripts?



Solution 1:[1]

I just encountered something similar, but the cause was different.

I was trying to use the dropdb command and what I was seeing was like my command having no effect (change of prompt means my command is in the buffer, but that's not the issue here):

postgres=# dropdb databasename
postgres-#

Commands like dropdb should be entered OUTSIDE psql. What i had been doing was:

$ psql postgres
postgres=# dropdb databasename

Notice the first command is in Bash and fires psql, and the second is sent within psql.

The correct way is to send the command directly in bash (the console):

$ dropdb databasename

Hope this helps a few people.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 benjamin ratelade