CLoudSQL permission to create schema - postgresql

I am trying to create a schema in my CloudSQL postgresql instance.
My service account user has the below roles assigned:
Cloud SQL Client
Cloud SQL Editor
Cloud SQL Instance User
And on executing the create schema command I am getting the error:
ERROR: permission denied for database *******
The google doc didn't seem to be clear on the role for specific PostgreSQL commands.
Am I doing something wrong? This works if I give CloudSQL Admin role.

Related

Enabling pg_cron extension on postgres database without rds_superuser

I'm trying to follow this article to enable the pg_cron extension on my postgres RDS instance on AWS:
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL_pg_cron.html
it says to run on the rds_superuser
CREATE EXTENSION pg_cron;
However, I'm logged in under a different user, I don't currently have access to the rds_superuser account. The message I get is:
SQL Error [42501]: ERROR: permission denied to create extension "pg_cron"
Hint: Must be superuser to create this extension.
Can anyone please tell me a work-around for this without having to contact a DBA? Can I grant superuser or create a new user with superuser to get around this?
it looks like the current user I have access to only shows on the pg_tables access to:
rolinherit - X
rolcanlogin - X
Ok I found out that if you go to your RDS database instance on AWS, you can "Modify" the RDS instance, and change the master password for the sysadmin user. I was then able sign in with this user and do what I needed to do.

Can't create new schema in an OVH postgres

I have a PostgreSQL server on OVH's Cloud DB and have been using its databases for my web apps.
So far so good.
I got a project where It's a requirement to have schemas. Strangely enough, I am unable to create schemas on the user with "Administrator" privileges.
I have prepared scripts using schemas, so I just need to run them on a prepared database but I need a database with schemas to run them.
Here is my process:
Create a new database
Select option "Create user"
Select option for privilages: "Administrator"
Commit configuration
Wait for database creation
Connect to database with the new config via PGAdmin
Run command create schema if not exists "vMobile";
Recieve following error:
ERROR: permission denied for database my-database-dev
SQL state: 42501
I created a ticket for this but the wait is taking too long.
Support answer
Ok, so I got a response from the OVH support and there is no option for the user to create new schemas as their CloudDB enables access only to schema public and mentioned privileges Administrator, Read/Write, Read, None are only applicable to the public schema.
Workaround
My solution to this is to create tables with schema name included in their names
like so:
Desired outcome: "vCommon"."Route"
Workaround: "public"."vCommon_Route"

Azure_superuser account password for Postgresql database on Azure

I have provisioned Azure Database for Postgresql, I'm trying to execute copy command in c# Azure function to load data from csv file to the database.
It throws an error saying ERROR: must be superuser to COPY to or from a file
The question is how do I use the user Azure_superuser, where do I get password for this account. This account is automatically created while setting up the PostgreSQL on Azure.
Because this is a PaaS service, you will not have access to the Super User account. You will have access to the Admin account:Azure PostgreSQL Server Admin Document

schema access for postgres database is fine from toad, but get a schema permission denied from an application

I have created a user role cadmin. When logged in as cadmin, I create a schema and create tables in the schema. This is with postgress 9.3
I am able to access the schema and query the tables perfectly fine from a tool like TOAD. However, from an application connected to the database, i always get an error that "permission is denied to the schema'. In the same application, I use jooq and that using the same role and the schema is able to find all the tables and create the classes. Just that when I do a 'Select' i get the error.
"nested exception is org.postgresql.util.PSQLException: ERROR: permission denied for schema core_engine"
You need to grant the permission for schema. So, you could try using following query from tool like TOAD and then run the application
GRANT USAGE ON SCHEMA schema_name TO postgres_user_name;

Enabling geodatabase in AWS RDS PostgreSQL instance

Superuser permission is required to create a geodatabase in PostgreSQL.
However, in AWS RDS instance we are receiving:
rds_superuser permission and rds_superuser is not superuser.
Is there a way to enable geodatabase in AWS RDS PostgreSQL with rds_superuser permission?
You need to create the database and the sde login manually using e.g. pgAdmin, and grant the rds_superuser group role to the sde login. Also create a schema named sde in your database, and make the sde login the owner of that schema.
Then you can create a .sde database connection in ArcCatalog using the sde login and, importantly, the *.rds.amazonaws.com hostname. Finally you can run the Enable Enterprise Geodatabase using this connection as your input.
This only works if you connect to the database using the *.rds.amazonaws.com hostname. Apparently, ESRI uses the hostname to determine if the database in question is an RDS server.
Once you've enabled the geodatabase you can connect to it with .sde connections using other dns aliases as well.
Refer to the ESRI documentation for further details: http://server.arcgis.com/en/server/latest/cloud/amazon/create-geodatabase-in-amazon-rds-for-postgresql.htm