Database Permissions
Create a database user for the platform on each input and output database, with the grants below. They are the minimum: your schema and the features you use may need more.
Triggers, procedures and other objects can need extra permissions. For example, if an AFTER INSERT trigger calls a procedure or uses a schema that ${user} can’t access, the workflow fails when it writes.
|
In each script, replace ${database}, ${user} and ${password} with your database name, the user’s name and its password. Use read grants on input databases and write grants on output databases.
It is a good idea to cap how many connections the user can open, so a workflow can’t overload the database. See Limit concurrent connections.
|
Use a dedicated output database. A run writes to the output and, depending on the workflow configuration, can empty its tables ( |
At a glance
A summary of the scripts below, to share with your DBA. Some databases have optional extra grants, which are in the scripts.
| Database | Input user (read) | Output user (write) |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL Server
-
Input database (read)
-
Output database (write)
use "${database}";
create login "${user}" with password = '${password}';
create user "${user}" for login "${user}";
grant select to "${user}";
grant view definition to "${user}";
use "${database}";
create login "${user}" with password = '${password}';
create user "${user}" for login "${user}";
grant
alter,
create table,
references,
insert,
update,
select,
delete
to "${user}";
PostgreSQL
-
Input database (read)
-
Output database (write)
create user "${user}" password '${password}';
grant connect on database "${database}" to "${user}";
/* If you use other schemas in your database, you should also explicitly
provide access to these schemas.
*/
grant select on all tables in schema "public" to "${user}";
create user "${user}" password '${password}';
grant connect on database "${database}" to "${user}";
grant create on database "${database}" to "${user}";
MySQL
-
Input database (read)
-
Output database (write)
create user "${user}" identified by "${password}";
grant select, show view on `${database}`.* to "${user}";
/*
Optional (required for diagnostic package)
show_routine privilege for MySQL 8.0.20 and later
*/
grant select on mysql.innodb_index_stats to "${user}";
grant show_routine on *.* to "${user}";
create user "${user}" identified by "${password}";
grant select, show view, alter, create, create view, delete, drop, index, insert, references, trigger, update on `${database}`.* to "${user}";
/*
Optional privileges
*/
grant create, select, insert, drop on tdklockholdingschema.* to "${user}";
Oracle
-
Input database (read)
-
Output database (write)
create user ${user} identified by "${password}"
/
grant create session to ${user}
/
grant unlimited tablespace to ${user}
/
-- Use this when users need metadata from objects they don’t own, such as for copying a schema.
GRANT SELECT_CATALOG_ROLE TO ${user}
/
begin
-- Use actual owner(s) instead of 'test' here
for r in (select owner, table_name from all_tables where owner='TEST') loop
execute immediate 'grant select on '||r.owner||'.'||r.table_name||' to ${user}';
end loop;
end;
/
SELECT_CATALOG_ROLE may be needed to copy a schema when the user works with objects it doesn’t own. Without it the platform still copies the schema, but the result might be inaccurate. If you need an exact copy of the schema, create it manually.
create user ${user} identified by "${password}"
/
grant create session to ${user}
/
grant unlimited tablespace to ${user}
/
grant
create any table,
create any view,
create any materialized view,
create any sequence,
create any index,
create any procedure,
alter any table,
alter any trigger,
drop any index,
drop any table,
drop any view,
drop any materialized view,
drop any sequence,
drop any procedure,
select any table,
select any sequence,
insert any table,
update any table,
delete any table
to ${user}
/
If you use the DISABLE_DB_INDEXES_ON_WRITE parameter, the user needs SELECT_CATALOG_ROLE, so the platform can check that SKIP_UNUSABLE_INDEXES is set to TRUE at system level.
Db2
Db2 uses operating system users, so create an OS user on the Db2 server before you grant permissions.
-
Input database (read)
-
Output database (write)
grant connect on database to user ${user};
@
begin
declare script varchar(1024);
declare sqlstate char(5) default '00000';
declare cur cursor for
select 'grant select on ' || rtrim(tabschema) || '.' || rtrim(tabname) || ' to ${user};'
from syscat.tables
where tabschema not like 'SYS%' and tabschema <> 'NULLID';
open cur;
rec_loop: LOOP
fetch cur into script;
if sqlstate ='02000' then leave rec_loop; end if;
execute immediate script;
end loop;
close cur;
end;
@
grant execute on function sysproc.db2_get_instance_info to ${user};
@
grant dbadm with dataaccess on database to user ${user};
@
Snowflake
Snowflake grants privileges to a role, which you then assign to the user the platform connects as. When you create the user, set its PASSWORD to your Snowflake programmatic access token (API token). Replace tdk_role, tdk_user, tdk_warehouse, mydb and myschema with your own names.
The platform writes with plain batched INSERT statements. It doesn’t use COPY INTO, stages or PUT.
-
Input database (read)
-
Output database (write)
-- Role and user (password = your Snowflake programmatic access token)
CREATE ROLE IF NOT EXISTS tdk_role;
CREATE USER IF NOT EXISTS tdk_user PASSWORD = '<api_token>' DEFAULT_ROLE = tdk_role;
GRANT ROLE tdk_role TO USER tdk_user;
-- Warehouse: USAGE is required to run any query
GRANT USAGE ON WAREHOUSE tdk_warehouse TO ROLE tdk_role;
-- Read the source schema and its tables (existing and future)
GRANT USAGE ON DATABASE mydb TO ROLE tdk_role;
GRANT USAGE ON SCHEMA mydb.myschema TO ROLE tdk_role;
GRANT SELECT ON ALL TABLES IN SCHEMA mydb.myschema TO ROLE tdk_role;
GRANT SELECT ON FUTURE TABLES IN SCHEMA mydb.myschema TO ROLE tdk_role;
-- Warehouse: USAGE to run queries, OPERATE to manage the running warehouse
GRANT USAGE, OPERATE ON WAREHOUSE tdk_warehouse TO ROLE tdk_role;
-- Database: create the target schema
GRANT USAGE, CREATE SCHEMA ON DATABASE mydb TO ROLE tdk_role;
-- Schema-level object creation (schema copy + a same-database probe table)
GRANT USAGE, CREATE TABLE, CREATE SEQUENCE, CREATE VIEW, CREATE TEMPORARY TABLE
ON SCHEMA mydb.myschema TO ROLE tdk_role;
-- Read + write on existing and future tables
GRANT SELECT, INSERT, UPDATE, TRUNCATE ON ALL TABLES IN SCHEMA mydb.myschema TO ROLE tdk_role;
GRANT SELECT, INSERT, UPDATE, TRUNCATE ON FUTURE TABLES IN SCHEMA mydb.myschema TO ROLE tdk_role;
|
In Snowflake,
|
Limit concurrent connections
Cap the number of connections the platform’s user can open so a workflow can’t overload the database:
| Database | How to limit connections |
|---|---|
SQL Server |
The server-wide user connections option. The default, 0, allows the maximum of 32,767 and lets SQL Server adjust the limit as needed. |
PostgreSQL |
Create the user with |
MySQL |
Set the account’s maximum number of simultaneous connections. The default, 0, means no limit. See account resource limits. |
Oracle |
Assign the user a profile with |
Db2 |
The |
If the database view shows an error
If the platform can’t read the table or column metadata of a connected database, the database view shows an error message instead of the schema explorer. The usual causes are missing permissions, connection details that are no longer valid, or a database that can’t be reached.
Read the message, fix the cause (for example, grant the missing permissions), then use the rescan or retry option in the database view to check the connection again.