Skip to content
Home » D1Admin Documentation » Managing Cloudflare D1 Tables

Managing Cloudflare D1 Tables

The basic D1 database table management operations that we can perform with D1Admin are:

  1. Creating D1 database tables
  2. Browsing tables
  3. Modifying table fields
  4. Adding new fields
  5. Drop/Delete a table

Creating Cloudflare D1 database tables

Creating tables is very easy with D1Admin. You will have all the available D1 data types, default values and index settings for selection from a drop down list or check box.

Start by entering table name and number of columns (later on we can always add additional columns and make changes if you need to):

table name d1 db

Then for each column we shall enter its name, data type, default value, whether it should allow NULL values, and is it part of a Primary Key or Index.
The common data types are: INTEGER, REAL, TEXT, BLOB

creating Cloudflare D1 database table

Finish by clicking on the Create button and the table structure will be ready. That’s it.

Browsing D1 database tables

Click on existing database table name and you will go into the table Browsing mode view.

browsing d1 tables

From here you can search for data, edit specific row or select a row for deletion.

Modifying table fields definition

If at some time you decide that a table field definition must be changed you can do so, by selecting the Structure tab of the table and then the Edit link corresponding to the field that must be modified.

and then applying the necessary changes to that field. After clicking Save, the changes will be applied.

Adding a new D1 table field

At any point in time we may add a new D1 table field(s). At the bottom of the Structure view tab, there is a text box where we can select how many additional table fields we need:

additional d1 table field

For the new table field(s) we can select from the same set of properties, as we did when initially creating the table (field name, data type, etc.) Selecting the Save button appends the new field(s) to the table and they will have the pre-selected DEFAULT values (or NULL values if the field(s) allows that).

Drop/Delete a table

We can DROP (delete) a D1 DB table by going to the Structure tab and selecting the Drop button corresponding to that particular table. A confirmation dialog will appear as this is an operation that must be executed with caution. (of course we can try to restore the database with the Time-travel feature of Cloudflare, but anyway be cautious!)

Summary

This tutorial is a short introduction to the D1Amin capabilities for managing Cloudflare(c) D1 database tables and performing operations for adding new tables and applying modifications to them.