Choose how careful a connection is
Each connection has a care level, which says what may run on it, and an environment, which tells production from a copy at a glance. Both are in Care, when you edit the connection.
On this page
The care level
Choose it in Changes:
| Level | Statements that change data | Statements that destroy data |
|---|---|---|
| Run as written (destroying asks) | Run | Ask |
| Ask before any change | Ask | Ask |
| Read-only | Refused | Refused |
A new connection has Ask before any change. The line at the bottom of the window says Asks before changes or Read-only.
When a statement asks, you see it whole, with Changes data or Destroys data, and nothing runs until you press Run.
What destroys data
DROPandTRUNCATEALTERwhen it drops somethingUPDATEandDELETEwithoutWHERE
How a statement is judged
TotalSQL reads the words of the statement. What it does not know counts as a change, so it may ask for a statement that changes nothing, such as SET. EXPLAIN ANALYZE counts as the statement that it explains, because it runs it.
The words do not say what a function does. So, with Ask before any change and Read-only, a statement that reads runs in PostgreSQL, MySQL, MariaDB and SQLite in a way that lets nothing be changed. If a function that it calls changes data, the database refuses it, and TotalSQL asks or refuses as with any other change. In SQL Server, functions cannot change data.
In MySQL and MariaDB, this does not work inside a transaction that you have open, nor while you hold tables withLOCK TABLES: there, aSELECTruns as it is.
Read-only
Besides refusing statements, TotalSQL opens the database itself as read-only in PostgreSQL, MySQL, MariaDB and SQLite. SQL Server has no such thing for a connection, so there the only guard is TotalSQL. For real safety, use a database user that can only read.
On a read-only connection, the buttons that change rows and tables are not there.
The other changes always show their SQL
Saving rows and changing a table show you their statements before they run, with any level but read-only. The changes proposed by an AI always ask.
The environment
Choose it in Environment. It is a mark next to the database, and it changes nothing in what may run:
| Environment | Mark |
|---|---|
| Local, Development, Testing | A green circle |
| Staging | An amber triangle |
| Production | A red square |
| None | No mark |