Edit data safely
You can change, add and delete rows from the Data tab. Every change is written to the database the moment you confirm it, so this page starts with the precautions.
Editing production data
Database Manager has no undo, no draft mode and no "apply changes" step. Save in the row editor and Run in the Query tab change the live database immediately. A deleted row, or an UPDATE without a WHERE, cannot be taken back from inside the app.
Before you change data that matters
- Take a backup first. Select Backup in the title bar and wait for Backup created. See Export and back up.
- Check which connection is open. The connection name is in the title bar. Give production connections a name that stands out, such as
PROD - orders. - Prefer a copy. Try the change on a test database or a restored backup first.
- Use a limited account. Connect with a database user that has only the rights the task needs. For looking around, use a read-only user: the database then refuses every change.
- Find the row before you edit it. Use the find-rows panel so that the row you click is the row you mean.
- Write the
WHEREfirst. In the Query tab, run aSELECTwith yourWHEREclause and check the rows it returns before you turn it into anUPDATEorDELETE. - Do not save production passwords. Turn on Ask for the password every time for those connections.
Edit a row
On the Data tab, click any cell of the row, or select the pencil button (Edit row) at its right end.
In the Edit row dialog, change the values you want. Each column has its own box.
To set a column to no value, tick NULL next to it. The box is disabled while NULL is ticked. Untick it to type a value again.
Select Save. A message confirms Row updated.
Select Cancel to close the dialog without changing anything.
How values are written:
- Text that looks like a number is stored as a number.
trueandfalseare stored as boolean values. Everything else is stored as text. - An empty box stores empty text, which is not the same as NULL.
- Save writes every column of the row, including the ones you did not touch.
WARNING
Avoid editing rows that contain binary data (shown as 0x…). The editor works with text, so the binary value may not be written back exactly as it was.
Insert a row
Select Insert in the toolbar.
In the Insert into dialog, fill in a value for each column.
For a column the database should fill itself, such as an auto-numbered
idin SQLite or MySQL, tick NULL.Select Save. A message confirms Row inserted.
If the database rejects the row, for example because a required column is empty, a message starts with Insert failed: and gives the database's reason. Nothing is added.
Delete a row
Select the red bin button (Delete row) at the right end of the row.
The app asks Delete row? and warns This cannot be undone.
Select Delete to remove the row, or Cancel to keep it.
Rows that cannot be edited
The app must be able to identify one exact row to change it. When it cannot, it shows This row cannot be edited (no row identifier). This happens for SQLite views and for SQLite tables created WITHOUT ROWID. Change those with a statement in the Query tab.
For MySQL tables without a primary key, the app finds the row by matching all of its column values and changes one matching row. If the table holds identical duplicate rows, you cannot choose which copy is changed.
Differences between databases
- MongoDB:
_idis shown as (read-only) and cannot be changed. A value that is valid JSON, such as42,true,["a","b"]or{"x":1}, is stored as that JSON type. Anything else is stored as text. - LMDB: a row is a
keyand avalue. A key is required. Changing the key of an existing entry removes the old key and writes the new one. Type0xfollowed by hexadecimal digits to enter binary data. - Tables whose names you do not see: the table list for PostgreSQL covers the
publicschema. Use the Query tab for other schemas.