MODIFIES SQL DATA is a data-access classification used in the SQL/PSM standard and several relational databases to label stored procedures or functions that change persistent data. When you create a routine, you must specify one of four access levels: NO SQL (no SQL at all), READS SQL DATA (only queries), MODIFIES SQL DATA (may change data), or CONTAINS SQL (unspecified but uses SQL). This classification lets the optimizer, permission system, and replication tools understand potential side effects. A routine marked MODIFIES SQL DATA can execute INSERT, UPDATE, DELETE, MERGE, TRUNCATE, DDL, or call other routines that do so. However, it is not implicitly granted write privileges; the routine owner still needs the necessary table permissions. Some dialects require MODIFIES SQL DATA for deterministic functions that update temporary tables, while others treat it as the default if no clause is given. Using the wrong clause may lead to runtime errors or blocked writes.
READS SQL DATA, NO SQL, CONTAINS SQL, CREATE FUNCTION, CREATE PROCEDURE, DETERMINISTIC
SQL:1999 (SQL/PSM)
It allows a function or procedure to run any statement that changes persistent data, including INSERT, UPDATE, DELETE, MERGE, or DDL.
Yes. If a routine performs DML you must declare MODIFIES SQL DATA (or leave the clause out, which defaults to MODIFIES) or the server returns an error.
You can call it, but the SELECT loses determinism and may be blocked in some configurations (e.g., read-only replicas). Use READS SQL DATA or NO SQL for pure queries.
No. It only describes potential side effects. You still control commits and rollbacks inside the routine or rely on implicit transactional behavior.