How to print current working directory in psql console?

Typing in the command \! pwd will print the current working directory in psql. To change working directory use command \cd <path>; replace <path> with desired path. Eg. Running command \cd /run/mount will change the current working directory to /run/mount. Try changing the your working directory to that containing the file which you want to … Read more

Create database from command line in PostgreSQL

Change the user to postgres : su – postgres Create User for Postgres (in the shell and NOT with psql) $ createuser testuser Create Database (same) $ createdb testdb Acces the postgres Shell psql ( enter the password for postgressql) Provide the privileges to the postgres user $ alter user testuser with encrypted password ‘qwerty’; … Read more

In psql, why do some commands have no effect?

Statements end with semicolons. In psql, pressing enter without a semicolon continues the statement onto the next line, adding what you wrote to the query buffer rather than executing it. You will notice that the prompt changes from dbname=> to dbname-> to indicate that you’re on a continuation line. regress=> DROP TABLE sometable regress-> \r … Read more

tech