Manage tables and records Retool Database
You can use the Database Editor to visually interact with tables and their records much like a spreadsheet. To access the Database Editor, sign in to your Retool organization and select the Database tab.
Manage tables
You can open multiple tables using the Database Editor, which appear as a list of tabs in the toolbar. Click or press to display a searchable list of tables and select one to open.
You can arrange or close tabs at any time, similar to how you would use multi-sheet spreadsheets. Closing a tab does not remove the table from Retool Database.
Create a table
Click + in the tab row to create a new table. You can either:
- Configure the table schema manually and create an empty table.
- Click Import CSV to import existing data.
Retool can automatically create the necessary schema when importing CSV data. Additional options are available to create a primary key column and whether to use an existing CSV column for the key.
Export tables
Retool exports table data in CSV format. To export a table, click to display a contextual menu and select Export data.
Change the primary key
Changing the primary key can cause existing queries that rely on it to function unexpectedly. Ensure you review any queries of the table to make sure they function correctly after updating the primary key.
Database tables use a primary key to uniquely identify each record, such as an ID number. If you need to change the primary key, click to display a contextual menu and select Edit Primary Key.
Copy table schema
You can create a new, empty table based on an existing table's schema. Open the Table options menu for an existing table and select Copy schema. Retool creates a new table and configures it with the same fields.
Tables created using an existing schema do not have a primary key set and are initially read-only. You must configure a primary key before you can edit table data.
Manage fields
To add a new field, click the + button to the right of the last field. Specify the name and type, then click Save. You can also add a new field to the left or right of existing fields. Click the field name to open the Field options menu and select either Insert field left or Insert field right.
Set field type
You can set a field's type, which reflects the data it contains. Click the field name to open the Field options menu and select Settings, or configure it when adding a new field. Each type includes additional options for configuration.
Setting the correct field type helps ensure that only valid data is entered. It also configures additional methods of input and determines how best to filter data. Some examples include:
- Date and Date + Time: Input dates using a date picker.
- Boolean: Toggle Boolean values using a checkbox.
- Enum: Configure a list of possible values from which to select.
Configure advanced field options
If you need more control over a field, click Advanced to set advanced options. You can configure the PostgreSQL type, default field value, and whether a field should allow null (nullable) or require unique values. Refer to PostgreSQL's official documentation to learn more about PostgreSQL schemas and data types.
Customize view options for fields
Click the Fields button in the toolbar to customize how fields appear in the Database editor UI. You can change the order of fields, pin a single field to the left, and toggle visibility.
Pin a field
A pinned field is fixed to the left of the Database editor UI and is always visible when scrolling horizontally. Click and drag a field to the Pinned section to pin it.
You can also pin a field from its Field options menu by clicking Pin this field.
Reorder fields
You can drag-and-drop fields to reorder them in the Database editor UI. Click and drag fields into different positions to change their order.
Hidden fields
If you need to work with large tables with many fields, you can hide fields that you don't need to use. Toggle the switch to the right of a field's name to show or hide fields. When there are hidden fields, the Fields button remains active and displays the number of hidden fields.
You can also hide a field from its Field options menu by clicking Hide this field.
Add a record
Click Add record to save new data to the current table. This opens the Add record modal that contains input fields generated from the current table's schema. Each input reflects the field's type, whether the field is nullable, and any default value.
After completing the form, click Create to save the record to the table.
Edit a record
You can also edit existing records using the same modal by clicking the Expand button that appears when hovering the cursor over a record.
To delete records, select them using the checkbox and click the red Delete button at the bottom of the window.
You cannot undo changes or the deletion of records in the Database editor UI. We strongly recommend you export table data as a CSV before making any significant changes.
Search records
Click Quick find or press and enter a search term to search through all records in the current table. Any results are highlighted and you can move between results using the search box.
Filter records
Click Filter to define filter conditions and show only records that match all of them. For example, you can show only records with a quantity
field value less than 9000
and contain the
in the name
field value.
You can add field filters from the Field options menu. Click the field name in the header and select Filter by this field.
Click Apply filter to filter records. The Filter button remains active while filters are applied and displays the number of filter conditions in use. To disable the filter, remove all filters and click Apply filter again.
Sort records
You can sort records by multiple fields in ascending or descending order. Click the Sort button to select fields and specify sort order. You can configure sorting to use multiple fields. In the event that multiple records have the same field values, the next field sorting option is applied.
You can quickly add fields for sorting from the Field options menu. Click the field name in the header and select either Sort ascending or Sort descending.
Click Apply to sort records. The Sort button remains active while sorting is applied and displays the number of sorting options in use. To disable sorting, remove all sorting options and click Apply again.