iflytek/astron-agent · warning · BusinessException
DATABASE_TABLE_NAME_EXIST
DATABASE_TABLE_NAME_EXIST
Error message
DATABASE_TABLE_NAME_EXIST
What it means
Thrown by DatabaseService.createDbTable when a non-deleted table with the same name already exists in the target database (count query on name+dbId+deleted=false returns > 0). Table names must be unique within a database, so the DDL is never issued. It is an expected, user-facing validation error.
Solutions
- List existing tables in the database and pick a unique name
- Reuse or alter the existing table instead of creating a new one
- Delete the old table if it is no longer needed, then retry
- Make bulk-creation scripts idempotent (skip existing names)
Example fix
// before
DbTableDto dto = new DbTableDto();
dto.setDbId(dbId);
dto.setName("events"); // may already exist
databaseService.createDbTable(dto);
// after
long exists = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()
.eq(DbTable::getName, "events").eq(DbTable::getDbId, dbId).eq(DbTable::getDeleted, false));
if (exists == 0) { databaseService.createDbTable(dto); } Defensive patterns
Strategy: validation
Validate before calling
long dup = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()
.eq(DbTable::getName, name).eq(DbTable::getDbId, dbId).eq(DbTable::getDeleted, false));
if (dup > 0) { /* choose another table name */ } Try / catch
try { databaseService.createDbTable(dto); } catch (BusinessException e) { if ("DATABASE_TABLE_NAME_EXIST".equals(e.getCode())) { /* prompt for a new name or reuse existing table */ } else { throw e; } } Prevention
- Check existing table names in the UI as the user types
- Make seed/import scripts idempotent
- Debounce create buttons to prevent duplicate submits
When it happens
Trigger: createDbTable called with a name equal to an existing non-deleted table in the same db; retrying a create that already succeeded; case-variant names that the DB treats as duplicates.
Common situations: Double-click on 'create table'; re-running an import/seed script without idempotency; renaming semantics where the old table still exists under a similar name; copy of table definitions across databases with same names in the target.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/919b8db558a04fbf.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java:293
try {
DbInfo dbInfo = dbInfoMapper.selectById(dbTableDto.getDbId());
if (dbInfo == null) {
throw new BusinessException(ResponseEnum.DATABASE_NOT_EXIST);
}
// Table count limit
Long tableCount = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()
.eq(DbTable::getDbId, dbInfo.getDbId())
.eq(DbTable::getDeleted, false));
if (tableCount > 20) {
throw new BusinessException(ResponseEnum.DATABASE_COUNT_LIMITED);
}
// Duplicate table name validation
Long count = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()
.eq(DbTable::getName, dbTableDto.getName())
.eq(DbTable::getDbId, dbInfo.getDbId())
.eq(DbTable::getDeleted, false));
if (count > 0) {
throw new BusinessException(ResponseEnum.DATABASE_TABLE_NAME_EXIST);
}
// Build DDL statement and validate required system fields
if (dbTableDto.getFields() == null || dbTableDto.getFields().isEmpty()) {
throw new BusinessException(ResponseEnum.DATABASE_TABLE_FIELD_CANNOT_EMPTY);
}
// Table fields cannot exceed 20
if (dbTableDto.getFields().size() > 20) {
throw new BusinessException(ResponseEnum.DATABASE_FIELD_CANNOT_BEYOND_20);
}
// Save information
DbTable dbTable = new DbTable();
BeanUtils.copyProperties(dbTableDto, dbTable);
dbTable.setCreateTime(new Date());
dbTable.setUpdateTime(new Date());
dbTableMapper.insert(dbTable);
List<String> systemFields = Arrays.asList(SYSTEM_FIELDS);
List<DbTableField> fields = new ArrayList<>();
for (DbTableFieldDto field : dbTableDto.getFields()) {View on GitHub (pinned to 5e758547a8)