<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Lakebase synced tables: how can a database owner/admin configure default SELECT privileges for the m in Lakebase Discussions</title>
    <link>https://community.databricks.com/t5/lakebase-discussions/lakebase-synced-tables-how-can-a-database-owner-admin-configure/m-p/175402#M154</link>
    <description>&lt;H3&gt;Question&lt;/H3&gt;&lt;P&gt;We use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Databricks Lakebase synced tables&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to sync Unity Catalog tables into Lakebase. We want a reader role to automatically receive&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;SELECT&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;access on newly created synced tables, without having to rerun grants whenever another table is added.&lt;/P&gt;&lt;P&gt;Granting access to existing tables works:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;GRANT USAGE ON SCHEMA target_schema TO reader_role;
GRANT SELECT ON ALL TABLES IN SCHEMA target_schema TO reader_role;&lt;/LI-CODE&gt;&lt;P&gt;However, synced tables are owned by a managed role named&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;databricks_writer_&amp;lt;database_oid&amp;gt;, rather than the identity running our migrations. Therefore, setting default privileges for the migration identity does not appear to cover future synced tables.&lt;/P&gt;&lt;P&gt;We tried explicitly configuring defaults for the managed writer role:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ALTER DEFAULT PRIVILEGES
FOR ROLE "databricks_writer_16840"
IN SCHEMA target_schema
GRANT SELECT ON TABLES TO reader_role;&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;I am running this as an admin and database owner&lt;/STRONG&gt;&lt;SPAN&gt;, but it fails with:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ERROR: permission denied to change default privileges&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;The same statement also fails when executed through Liquibase inside a PostgreSQL&amp;nbsp;DO&amp;nbsp;block:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ERROR: Exception Primary Class: PSQLException
ERROR: Exception Primary Reason:
ERROR: permission denied to change default privileges

Where: SQL statement
"ALTER DEFAULT PRIVILEGES FOR ROLE databricks_writer_16840
 IN SCHEMA target_schema GRANT SELECT ON TABLES TO reader_role"

PL/pgSQL function inline_code_block line 14 at EXECUTE&lt;/LI-CODE&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Pat.&lt;/P&gt;</description>
    <pubDate>Mon, 02 Nov 2026 20:01:27 GMT</pubDate>
    <dc:creator>Pat</dc:creator>
    <dc:date>2026-11-02T20:01:27Z</dc:date>
    <item>
      <title>Lakebase synced tables: how can a database owner/admin configure default SELECT privileges for the m</title>
      <link>https://community.databricks.com/t5/lakebase-discussions/lakebase-synced-tables-how-can-a-database-owner-admin-configure/m-p/175402#M154</link>
      <description>&lt;H3&gt;Question&lt;/H3&gt;&lt;P&gt;We use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Databricks Lakebase synced tables&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to sync Unity Catalog tables into Lakebase. We want a reader role to automatically receive&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;SELECT&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;access on newly created synced tables, without having to rerun grants whenever another table is added.&lt;/P&gt;&lt;P&gt;Granting access to existing tables works:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;GRANT USAGE ON SCHEMA target_schema TO reader_role;
GRANT SELECT ON ALL TABLES IN SCHEMA target_schema TO reader_role;&lt;/LI-CODE&gt;&lt;P&gt;However, synced tables are owned by a managed role named&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;databricks_writer_&amp;lt;database_oid&amp;gt;, rather than the identity running our migrations. Therefore, setting default privileges for the migration identity does not appear to cover future synced tables.&lt;/P&gt;&lt;P&gt;We tried explicitly configuring defaults for the managed writer role:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ALTER DEFAULT PRIVILEGES
FOR ROLE "databricks_writer_16840"
IN SCHEMA target_schema
GRANT SELECT ON TABLES TO reader_role;&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;I am running this as an admin and database owner&lt;/STRONG&gt;&lt;SPAN&gt;, but it fails with:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ERROR: permission denied to change default privileges&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;The same statement also fails when executed through Liquibase inside a PostgreSQL&amp;nbsp;DO&amp;nbsp;block:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ERROR: Exception Primary Class: PSQLException
ERROR: Exception Primary Reason:
ERROR: permission denied to change default privileges

Where: SQL statement
"ALTER DEFAULT PRIVILEGES FOR ROLE databricks_writer_16840
 IN SCHEMA target_schema GRANT SELECT ON TABLES TO reader_role"

PL/pgSQL function inline_code_block line 14 at EXECUTE&lt;/LI-CODE&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Pat.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2026 20:01:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/lakebase-discussions/lakebase-synced-tables-how-can-a-database-owner-admin-configure/m-p/175402#M154</guid>
      <dc:creator>Pat</dc:creator>
      <dc:date>2026-11-02T20:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Lakebase synced tables: how can a database owner/admin configure default SELECT privileges for t</title>
      <link>https://community.databricks.com/t5/lakebase-discussions/lakebase-synced-tables-how-can-a-database-owner-admin-configure/m-p/175404#M155</link>
      <description>&lt;P&gt;Hi Pat,&lt;/P&gt;&lt;P&gt;That error is expected. ALTER DEFAULT PRIVILEGES FOR ROLE can only be run by members of that role.&lt;/P&gt;&lt;P&gt;The Lakebase docs say it in their own example: "only members of table_creator_role_name can run this command". databricks_writer_16840 is the internal role the sync pipeline uses to own synced tables, and your admin identity isn't a member of it. Default privileges are also tied to the role that creates the object, so defaults set for your migration identity will never apply to synced tables.&lt;/P&gt;&lt;P&gt;Two options that work within the documented model:&lt;/P&gt;&lt;P&gt;1. Grant pg_read_all_data to the reader role&lt;/P&gt;&lt;P&gt;databricks_superuser inherits pg_read_all_data, which is how it reads synced tables without per-table grants. Granting the same predefined role to your reader covers every current and future table, synced ones included:&lt;/P&gt;&lt;P&gt;GRANT pg_read_all_data TO reader_role;&lt;/P&gt;&lt;P&gt;The catch is scope. It applies to all schemas in the database, not just target_schema. If other schemas hold data the reader shouldn't see, it's too broad. Test it first with your admin role, since granting predefined roles needs CREATEROLE or admin rights.&lt;/P&gt;&lt;P&gt;2. Re-run the grant right after each synced table is created&lt;/P&gt;&lt;P&gt;Keep your current GRANT SELECT ON ALL TABLES IN SCHEMA target_schema as a step that runs right after the job or migration that creates the synced table. It's idempotent and cheap, and the access stays limited to target_schema. Since you already sync into a dedicated schema, this is the cleanest option if least privilege matters.&lt;/P&gt;&lt;P&gt;Docs:&lt;BR /&gt;Synced tables, ownership and granting access: &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/sync-tables" target="_blank"&gt;https://docs.databricks.com/aws/en/oltp/projects/sync-tables&lt;/A&gt;&lt;BR /&gt;Default privileges in Lakebase: &lt;A href="https://learn.microsoft.com/en-us/azure/databricks/oltp/projects/manage-roles-permissions" target="_blank"&gt;https://learn.microsoft.com/en-us/azure/databricks/oltp/projects/manage-roles-permissions&lt;/A&gt;&lt;BR /&gt;Postgres predefined roles: &lt;A href="https://www.postgresql.org/docs/current/predefined-roles.html" target="_blank"&gt;https://www.postgresql.org/docs/current/predefined-roles.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2026 21:45:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/lakebase-discussions/lakebase-synced-tables-how-can-a-database-owner-admin-configure/m-p/175404#M155</guid>
      <dc:creator>ThomazNeto</dc:creator>
      <dc:date>2026-11-02T21:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Lakebase synced tables: how can a database owner/admin configure default SELECT privileges for t</title>
      <link>https://community.databricks.com/t5/lakebase-discussions/lakebase-synced-tables-how-can-a-database-owner-admin-configure/m-p/175412#M157</link>
      <description>&lt;P&gt;Hello Pat,&lt;/P&gt;
&lt;P&gt;Following up on the answer above from &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/245135"&gt;@ThomazNeto&lt;/a&gt;.&amp;nbsp;I did a test run, particularly on one option the thread has not covered yet. Thank you for posting the exact statements and both errors, which made the case easy to reproduce&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Short answer:&lt;/STRONG&gt; Thomaz's diagnosis is right, and both options in that answer worked in my test. An event trigger gives you the behavior you asked for: it grants SELECT on each newly synced table when the sync pipeline creates it, so nothing needs to be rerun.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LingeshK_1-1793672711577.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/32906i9008855E650CA3EC/image-size/large?v=v2&amp;amp;px=999" role="button" title="LingeshK_1-1793672711577.png" alt="LingeshK_1-1793672711577.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Why the statement fails:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Ownership:&lt;/STRONG&gt; &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/sync-tables#ownership-and-permissions" target="_blank"&gt;A synced table is owned by the internal databricks_writer role for its database&lt;/A&gt;, because the pipeline creates it. On my test project, the database OID was 16407, and the role was&lt;CODE&gt;databricks_writer_16407&lt;/CODE&gt;, so your reading of the suffix is right.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Default privileges:&lt;/STRONG&gt; Postgres lets you change &lt;A href="https://www.postgresql.org/docs/current/sql-alterdefaultprivileges.html" target="_blank"&gt;the defaults of roles that you are a member of&lt;/A&gt;, and a new object gets only the defaults of its creator. The &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/manage-roles-permissions#grant-permissions-to-postgres-roles" target="_blank"&gt;Lakebase example&lt;/A&gt; says "only members of table_creator_role_name can run this command". Liquibase and the DO block still run as the same role, so they fail the same way.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Joining the writer role:&lt;/STRONG&gt; &lt;CODE&gt;GRANT databricks_writer_16407&lt;/CODE&gt;&amp;nbsp;Joining the writer role failed with "Only roles with the ADMIN option on role ... may grant this role." The writer is one of the &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/postgres-roles#system-roles-created-by-databricks" target="_blank"&gt;system roles Databricks creates for internal services&lt;/A&gt;, and the docs give no way to join it.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Q1.&lt;/STRONG&gt; "We want a reader role to automatically receive SELECT access on newly created synced tables, without having to rerun grants whenever another table is added."&lt;/P&gt;
&lt;P&gt;All three worked in my test:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Event trigger:&lt;/STRONG&gt; The &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/lakebase-cdf#step-1-set-replica-identity-full" target="_blank"&gt;change data feed setup&lt;/A&gt; installs an event trigger that "runs after every CREATE TABLE". The sync pipeline's CREATE TABLE fires it too. In my test, the trigger ran as &lt;CODE&gt;databricks_writer_16407&lt;/CODE&gt;, the owner of the new table, so its GRANT succeeded and &lt;CODE&gt;reader_role&lt;/CODE&gt; could read the table at once. Postgres reserves event triggers for superusers. On Lakebase, &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/compatibility#roles-and-permissions" target="_blank"&gt;databricks_superuser takes the place of the Postgres superuser role&lt;/A&gt;, and the project owner created the trigger in my test. The trigger covers new tables only, so run your current GRANT once for the tables you have today. The code is below.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;pg_read_all_data:&lt;/STRONG&gt; &lt;CODE&gt;GRANT pg_read_all_data TO reader_role&lt;/CODE&gt; succeeded as the project owner. Postgres says &lt;A href="https://www.postgresql.org/docs/current/sql-grant.html" target="_blank"&gt;the grantor must have ADMIN OPTION on the target role&lt;/A&gt;, which CREATEROLE alone does not give. The recorded grantor was &lt;CODE&gt;databricks_superuser&lt;/CODE&gt;, which holds that option. The reach is wider than one database. Postgres roles are &lt;A href="https://www.postgresql.org/docs/current/database-roles.html" target="_blank"&gt;global across a database cluster&lt;/A&gt;, and new databases &lt;A href="https://www.postgresql.org/docs/current/ddl-priv.html" target="_blank"&gt;give CONNECT to PUBLIC by default&lt;/A&gt;. In my test the reader could read a table in a second database on the same branch.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Rerun the grant:&lt;/STRONG&gt; This works and stays inside &lt;CODE&gt;target_schema&lt;/CODE&gt;. A Snapshot resync kept the same table, and the grant survived it. &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/sync-tables#delete-a-synced-table" target="_blank"&gt;Deleting a synced table drops the Postgres table&lt;/A&gt; and its grants, and &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/sync-tables#accelerated-sync-with-ltap-direct-writes" target="_blank"&gt;adding LTAP Direct Writes&lt;/A&gt; takes a delete and re-create. So a rerun is needed for new and re-created tables. To hook it in, &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/sync-tables#schedule-or-trigger-subsequent-syncs" target="_blank"&gt;add the sync pipeline to a Lakeflow job as a Database Table Sync pipeline task&lt;/A&gt; and run the grant in a task after it.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;A view layer in a schema that your migration identity owns also works with ordinary default privileges. Each new synced table still needs its own CREATE VIEW, and a view built with &lt;CODE&gt;*&lt;/CODE&gt; &lt;A href="https://www.postgresql.org/docs/current/sql-createview.html" target="_blank"&gt;leaves out columns added to the table later&lt;/A&gt;.&lt;/P&gt;
&lt;PRE&gt;-- Once, for the synced tables you have today
GRANT USAGE ON SCHEMA target_schema TO reader_role;
GRANT SELECT ON ALL TABLES IN SCHEMA target_schema TO reader_role;

-- From now on, grant SELECT on each table created in target_schema
CREATE OR REPLACE FUNCTION public.grant_select_on_new_synced_tables()
RETURNS event_trigger
LANGUAGE plpgsql
AS $$
DECLARE
  obj record;
BEGIN
  FOR obj IN
    SELECT * FROM pg_event_trigger_ddl_commands()
    WHERE schema_name = 'target_schema' AND object_type = 'table'
  LOOP
    BEGIN
      EXECUTE format('GRANT SELECT ON %s TO reader_role', obj.object_identity);
    EXCEPTION WHEN OTHERS THEN
      -- Warn and carry on, so the CREATE TABLE of the sync pipeline never fails
      RAISE WARNING 'grant on % failed: %', obj.object_identity, SQLERRM;
    END;
  END LOOP;
END;
$$;

CREATE EVENT TRIGGER grant_select_on_new_synced_tables
  ON ddl_command_end
  WHEN TAG IN ('CREATE TABLE')
  EXECUTE FUNCTION public.grant_select_on_new_synced_tables();

-- After the next synced table appears, this returns true
SELECT has_table_privilege('reader_role', 'target_schema.new_synced_table', 'SELECT');&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Before you rely on this:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Testing:&lt;/STRONG&gt; I ran every statement above on 3 November 2026 on a Lakebase Autoscaling project with Postgres 17.11, as the project owner, with Snapshot synced tables. I did not test Postgres 16, or the Triggered and Continuous modes. No doc page says that the CREATE TABLE of the sync pipeline fires your own triggers. That part rests on the test, so check it again after a platform upgrade.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Failure handling:&lt;/STRONG&gt; If a ddl_command_end trigger fails, &lt;A href="https://www.postgresql.org/docs/current/event-trigger-definition.html#EVENT-TRIGGER-ABORTED-TRANSACTIONS" target="_blank"&gt;Postgres rolls back the DDL statement&lt;/A&gt;, here the CREATE TABLE of the pipeline. The function catches errors and raises a warning instead. I tested that path with a role that does not exist, and the synced table still came online.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;One trigger per database:&lt;/STRONG&gt; Event triggers &lt;A href="https://www.postgresql.org/docs/current/event-triggers.html" target="_blank"&gt;are global to a particular database&lt;/A&gt;, so create one in each database that holds synced tables.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Happy to look at the output if you try the trigger on your side. Results on Postgres 16 or with Continuous mode would also help here.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2026 02:25:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/lakebase-discussions/lakebase-synced-tables-how-can-a-database-owner-admin-configure/m-p/175412#M157</guid>
      <dc:creator>LingeshK</dc:creator>
      <dc:date>2026-11-03T02:25:38Z</dc:date>
    </item>
  </channel>
</rss>

