All Products
Search
Document Center

PolarDB:ST_ImportObj

Last Updated:Mar 28, 2026

Imports an OBJ file from an Object Storage Service (OSS) bucket or binary stream into a database.

Syntax

boolean ST_ImportObj(text table_name, text url,     text id, text options default '{}');
boolean ST_ImportObj(text table_name, bytea content, text id, text options default '{}');

Return values

Return valueDescription
trueThe file was imported successfully.
falseThe file failed to import.

Parameters

ParameterTypeDescription
table_nametextThe name of the OBJ table and the prefix of the corresponding sharded table.
urltextThe path of the OBJ file in an OSS bucket.
contentbyteaThe OBJ file as a binary stream.
idtextThe ID of the OBJ file.
optionstextImport options as a JSON string. Defaults to {}. See Import options for valid keys.

Limitations

Only diffusetexture type textures are supported. Texture files of other types are ignored during import.

Import options

Pass options as a JSON string to the options parameter.

OptionTypeDefaultDescriptionExample
schemastringpublicThe schema of the target table.postgres
search_pathstringParent path of the OBJ file URL; empty if content is used.The search path for material and texture files.OSS://foo/bar
ignore_missingBooleantrueSpecifies whether to ignore errors when material or texture files are not found.false
force_triangulateBooleantrueSpecifies whether to force triangulation of non-triangular faces.false
metallic_roughnessBooleantrueSpecifies whether to parse materials as metallic_roughness type. Set to false to parse as specular_glossiness type.true
obj_data_columnstringobj_dataThe data field name in the primary table.my_data
obj_id_columnstringobj_idThe ID field name in the primary table.my_id

Table schemas

ST_ImportObj creates three tables on import: a primary table, a component table, and a texture table.

Primary table

FieldTypeDescription
idserialThe primary key.
[obj_id_column]textThe ID of the data record. Field name is configurable via obj_id_column; defaults to obj_id.
[obj_data_column]sfmeshThe mesh data. Field name is configurable via obj_data_column; defaults to obj_data.

Component table

FieldTypeDescription
idserialThe primary key.
obj_idtextThe ID of the data record. Fixed field name.
component_idtextThe sequence number of the component in the original OBJ file.
nametextThe group or object name of the OBJ file. If multiple names exist, the first is used. Defaults to Mesh_[object sequence number].
tagsjsonbThe tags of the OBJ file.
componentsfmeshThe component name.

Texture table

FieldTypeDescription
idserialThe primary key.
obj_idtextThe ID of the data record. Fixed field name.
texture_idtextThe sequence number of the texture in the original OBJ file.
nametextThe file name of the texture.
texturetextureThe texture name.

Examples

Import an OBJ file from OSS

SELECT ST_ImportObj('test_obj', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_obj.obj');

Returns:

---------
t

Import with forced triangulation disabled

SELECT ST_ImportObj('test_obj', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_obj.obj', '{"force_triangulate": false}');

Returns:

---------
t