Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insufficient privileges to operate on schema 'PUBLIC'

I created a user ANALYST_USER and granted a role ANALYST.

When I tried to create a table in the TEST_DB, I got a following error message: Unable to create table TEST. SQL access control error: Insufficient privileges to operate on schema 'PUBLIC'

enter image description here

Here are the statements I wrote before trying to create a table using the ANALYST_USER account.

USE ROLE SECURITYADMIN;

-- Create Role-- CREATE ROLE ANALYST

-- Database-- GRANT USAGE ON DATABASE TEST_DB TO ROLE ANALYST;

-- Schema-- GRANT USAGE, MONITOR ON ALL SCHEMAS IN DATABASE TEST_DB TO ROLE ANALYST; GRANT USAGE, MONITOR ON FUTURE SCHEMAS IN DATABASE TEST_DB TO ROLE ANALYST;

-- Warehouse-- GRANT USAGE ON WAREHOUSE TEST_WH TO ROLE ANALYST; GRANT USAGE ON WAREHOUSE TEST_WH TO ROLE ANALYST;

-- Tables/Views-- GRANT SELECT ON ALL TABLES IN DATABASE TEST_DB TO ROLE ANALYST; GRANT SELECT ON FUTURE TABLES IN DATABASE TEST_DB TO ROLE ANALYST;

-- User -- GRANT ROLE ANALYST to USER ANALYST_USER;

Does anyone know how to solve this issue?

like image 551
knozawa Avatar asked Oct 28 '25 05:10

knozawa


1 Answers

It is because the role was missing create table rights on the public schema. You just have usage and monitor privileges in your schema grant. So, GRANT CREATE TABLE ON SCHEMA TEST_DB.PUBLIC TO ROLE ANALYST; would have solved your issue.

like image 159
SQLGuyChuck Avatar answered Oct 30 '25 13:10

SQLGuyChuck