I am using PostgreSQL as my database along with Prisma as my ORM.It seems to be giving an issue while running the 'prisma migrate' command on the server which seems to be an issue of user database privileges not being present.What are the basic user privileges that are required for Prisma while using Postgres apart from the option of giving full admin rights?
Database user needs to have a CREATEDB privilege for using migrate commands in PostgreSQL.
Here's a reference to privileges needed for each supported database: Reference.
I have several Heroku Postgres databases that I want to access using pgAdmin4. I'm using version 4.2. I used this link to learn how to hide the databases I don't have access to. I have all the databases entered in DB restriction. However when I connect to the Heroku database, only the maintenance account appears in the list of databases. I updated the password file in advanced properties with my .pgpass file. It still only lists the maintenance database.
I've searched here, the Database Administrators Stack Exchange, and the pgAdmin instructions but have not found anything.
I'm trying to run a postgresql Database on Ubuntu 16.04 LTS.
First I installed postgres using sudo apt-get install postgresql which installed version 9.5.1. I then created another user and a new database. I've granted all privileges for the new database to new new user and set the owner to the new user also.
I connected to the new database and filled it by restoring an plain backup (dump) I've created from another database (which has postgresql version 9.2) by using \i /path/to/dump.sql. I got no errors, and when I then typen \dt I got the list with the tables.
The problem is: When I now disconnect (\q) and re-connect (same as I connected before, sudo psql -U "username" dbname) and type \dt again, it says "No relations found". When I try to fill it again, I get a bunch of errors like "Relation relationname already exists".
Another problem/symptom appears when I try to use pgAdmin (installed via sudo apt-get install pgadmin3). When trying to connect using localhost, I can't connect using the newly created user (which which I can connect from the terminal). But I can connect using postgres with the password I set via Terminal. I do not see any DB I manually create from command line from pgAdmin tho.
So yeah, my guess is that at least one problem may be version incompatibility between 9.2 and 9.5. Is there any way to test/fix this? But I also think there should be other problems.
What you describe may happen if the SQL dump contains a SET search_path TO...command that sets it to a different value than what your user has by default.
So not only it will create its tables and other objects in that schema, but it will leave that search_path for the rest of the session, so when you do \dt in that same session, it does see and list the newly created tables.
But when you quit and reenter psql, this search_path is not longer in effect, you're back to the default search_path of your user, which supposedly doesn't reach the schema, so \dt no longer "sees" any table.
You can use show search_path to check this setting in a psql session, and grep "SET search_path" in the SQL file to check what it's being set to.
Per comment, it appears to be the case: the dump creates the tables into a schema that is outside of the user's default search path.
A possible solution for that user to work seamlessly would be to update its search path so that it always reaches this schema first. This can be done with:
ALTER USER username SET search_path TO schema1,"$user",public;
where schema1 is what the SQL dump refers to and where it created the tables.
I need to update a dababase from an other database... For this I need to search in existing database if the records exists, if not add... One of the database is locally stored in my computer, and the other one is on heroku... But I don't know how to access heroku database from my computer to create the inserts and to query if I have to insert or not...
Any idea how can I do something like this?
You can connect via any DB tool, e.g. Oracle SQL Developer with Postgres JDBC connector, to a Heroku Postgres DB. The parameters are listed in the GUI of postgres.heroku.com for your instance.
I have installed PostgreSQL DB server on my Ubuntu machine. Now I want to create a new Database through some GUI application. I tried pgAdmin but didn't find any option to create a new DB. But I could add existing db servers.
Is there any way to create a DB and then tables through pgAdmin or some other app.
Basically I am looking for an application for PostgreSQL like SQLYog for MySQL.
Open pgAdmin
Connect to database server
Edit => New Object => New database
done
Or use plain SQL when connection to any database: CREATE DATABASE my_database;
HI ... Verify that u have done above steps to install the postgresql properly ... and follow the below instructions to create a database in POSTGRESQL
INSTALL POSTGRESQL
1.Install latest PostgreSQL 9.1 in console:
sudo apt-get install postgresql libpq-dev
2.PostgreSQL has a super user is called postgres. Change user to the PostgreSQL user:
sudo su - postgres
3.Change password of postgres user:
psql -d postgres -U postgres
psql (9.1.3) Type "help" for help
postgres=# alter user postgres with password 'YOUR_NEW_PASSWORD';
ALTER ROLE
postgres=# \q
#logout postgres user
logout
4.Restart the PostgreSQL server:
sudo /etc/init.d/postgresql restart
pgAdmin III: PostgreSQL administration and management tools
If pgAdminIII is not installed, the installation is easy:
sudo apt-get install pgadmin3
ADD A SEVER
Open pgAdminIII and add new localhost server. Go to menu File > Add Server
Set up pgAdmin III server instrumentation:
When connecting to a PostgreSQL database using pgAdmin you may receive an error letting you know that the server instrumentation is not installed.
Install postgresql-contrib package:
sudo apt-get install postgresql-contrib
Install adminpack extension:
sudo -u postgres psql
postgres=# CREATE EXTENSION "adminpack";
postgres=# \q
CREATE DATABASE
1.Double Click your database in Left pane on PGAdmin to select it
2.Now click the a Icon named "SQL" ,probably 6th icon, and type CREATE table query in resultant window
EXAMPLE:
3.Create table query
CREATE TABLE explore(
SUBJECT TEXT NOT NULL,
COMPANY CHAR(50) NOT NULL,
PNAME TEXT NOT NULL,
PHONE INT NOT NULL,
EMAIL CHAR(50) NOT NULL,
REMARKS CHAR(200) NOT NULL
);
Post any queries below.............Have a error free day.
One of problems with DB creating is connected to permissions.
If there are no grant for creating database, the path "Object -> Create -> Database" is off (unclickable) and you can't pick this menu option. Likewise, "Databases -> Right Mouse Button" doesn't have "Create" option. One more sign of this case is the reaction in SQL:
CREATE DATABASE DBNAME;
ERROR: permission denied to create database
********** Error **********
To solve the problem you can reconnect to the Server with the first login ('postgres' for example). And afterwards the menu will work.
Of course you can create a database with pgAdmin.
You have to understand the basic concept of PostgreSQL. First you have to connect to a database cluster, which you can only do by connecting to a database in that cluster. Now, if your database does not exist, yet, there is the default maintenance db postgres you can connect to. Connect to it and issue CREATE DATABASE there. Then change to the new database.
On windows right click on the db connector
My db connector is PostgreSQL->Create->Database, expand the database
Next expand schema
under which tables is found, then right click, and create tables
To create tables Expand database->under that expand schema->under tables , click on create tables
To add columns and data types to tables
under the respective table, right click properties and select column fields and add name of columns, data types as needed properties->columns
So, I'm late to the party, but it seems that regular old PG_Admin, and the EnterpriseDB installation are different packages. PG_Admin by itself just manages and connects to servers, but doesn't seem to create them. This is definitely not clear, but yeah you get those errors because you're trying to connect to a server that doesn't exist. You could also use WSL to do this, but you'd have to have WSL and your server up and running everytime to you play.