Skip to content
Home » D1Admin Documentation » Working with data in D1

Working with data in D1

Each relational database and Cloudflare D1 as well, offers four basic operations with data: abbreviated with the acronym CRUD (Create, Read, Update, Delete) or basically selecting rows, creating data rows, updating and deleting. This tutorial illustrates how to perform those operation in visual manner with the D1Admin tool:

Browsing D1 database tables

In order to browse the table records in a D1 database table, simply click on existing table name and you will go into the table Browsing mode view.

Browsing D1 table

From the Browsing view you can edit and delete rows.

Inserting data in D1

Using D1Admin we can insert new rows in D1 database tables through a visual interface.

There are two common ways to go into the Insert tab for particular database table:

  • by selecting the Insert button for given table in the main Structure tab view:
D1Admin Insert button in Structure view
  • when a table has already been selected (for example in Browsing mode) from its Insert tab

Inserting NULL values
For each column if we want to put a NULL value, we just have to select the checkbox under the NULL column.

In the picture above you may notice that we cannot put a NULL value for the first column (test_id) as it has been created with the NOT NULL restriction (which is common for primary keys).

Function modifier
In the Insert tab, there is also a Function dropdown, which is a convenient way to specify built-in Cloudflare functions to be applied to the value that we enter for the corresponding column. For example:

  • for a TEXT column first_name we may enter Function: upper and Value: john and the resulting database record will have value JOHN

Updating data

A single row can be edited by selecting the Edit link at the row beginning.

We can update multiple rows at once by going to the Browse tab of the table to be updated and then selecting the checkboxes in front of the row(s) to be edited:

selecting D1 rows for edit/delete

After we have selected the desired records, we can select the operation With Selected: to be the Edit action (from the checkbox at the bottom of the table)

choosing operation for Cloudflare D1 database row(s)

Then a new screen similar to the one for Inserting data will be displayed where we can edit the pre selected row(s).

Deleting data from D1 tables

In the same way that we selected row(s) for update, we can also select which rows to delete. The only difference is that this time the action that we have to choose is Delete:

deleting D1 table row

Even if you have selected the Delete link or action by mistake, the operation still won’t be applied until you have made an explicit confirmation for that: