Back to Nocobase

External Database

docs/docs/en/data-sources/data-source-manager/external-database.md

2.0.484.8 KB
Original Source

External Database

Introduction

Use an existing external database as a data source. Currently supported external databases include MySQL, MariaDB, PostgreSQL, MSSQL, and Oracle.

Usage Instructions

Adding an External Database

After activating the plugin, you can select and add it from the "Add new" dropdown menu in data source management.

Fill in the information for the database you need to connect to.

Collection Synchronization

After establishing a connection with an external database, all collections within the data source will be read directly. External databases do not support adding collections or modifying the table structure directly. If modifications are needed, you can perform them through a database client and then click the "Refresh" button in the interface to synchronize.

Configuring Fields

The external database will automatically read and display the fields of existing collections. You can quickly view and configure the field's title, data type (Field type), and UI type (Field interface). You can also click the "Edit" button to modify more configurations.

Because external databases do not support modifying the table structure, the only available type when adding a new field is the association field. Association fields are not actual fields but are used to establish connections between collections.

For more details, see the Collection Fields/Overview chapter.

Field Type Mapping

NocoBase automatically maps the field types from the external database to the corresponding data type (Field type) and UI type (Field Interface).

  • Data type (Field type): Defines the kind, format, and structure of data that a field can store.
  • UI type (Field interface): Refers to the type of control used in the user interface to display and input field values.
PostgreSQLMySQL/MariaDBNocoBase Data TypeNocoBase Interface Type
BOOLEANBOOLEAN
TINYINT(1)booleancheckbox
switch
SMALLINT
INTEGER
SERIAL
SMALLSERIALTINYINT
SMALLINT
MEDIUMINT
INTEGERinteger
boolean
sortinteger
sort
checkbox
switch
select
radioGroup
BIGINT
BIGSERIALBIGINTbigInt
sortinteger
sort
checkbox
switch
select
radioGroup
unixTimestamp
createdAt
updatedAt
REALFLOATfloatnumber
percent
DOUBLE PRECISIONDOUBLE PRECISIONdoublenumber
percent
DECIMAL
NUMERICDECIMALdecimalnumber
percent
currency
VARCHAR
CHARVARCHAR
CHARstring
password
uuid
nanoidinput
email
phone
password
color
icon
select
radioGroup
uuid
nanoid
TEXTTEXT
TINYTEXT
MEDIUMTEXT
LONGTEXTtext
jsontextarea
markdown
vditor
richText
url
json
UUID-uuiduuid
JSON
JSONBJSONjsonjson
TIMESTAMPDATETIME
TIMESTAMPdatedate
time
createdAt
updatedAt
DATEDATEdateOnlydatetime
TIMETIMEtimetime
-YEARdatetime
CIRCLEcirclejson
circle
PATH
GEOMETRY(LINESTRING)LINESTRINGlineStringJson
lineString
POINT
GEOMETRY(POINT)POINTpointjson
point
POLYGON
GEOMETRY(POLYGON)POLYGONpolygonjson
polygon
GEOMETRYGEOMETRY--
BLOBBLOBblob-
ENUMENUMenumselect
radioGroup
ARRAY-arraymultipleSelect
checkboxGroup
BITBIT--
SETSETsetmultipleSelect
checkboxGroup
RANGE---

Unsupported Field Types

Unsupported field types are displayed separately. These fields require development adaptation before they can be used.

Filter Target Key

Collections displayed as blocks must have a Filter target key configured. The filter target key is used to filter data based on a specific field, and the field value must be unique. By default, the filter target key is the collection's primary key field. For views, collections without a primary key, or collections with a composite primary key, you need to define a custom filter target key.

Only collections that have a filter target key configured can be added to the page.