NoCodeBackend

Product details
PatrickBatemanPatrickBateman
PatrickBatemanPLUS
Sep 28, 2026

Q: Question

Hey I submitted through the contact form but not sure if it went through: I have an existing nullable VARCHAR(64) column named business_fingerprint on an existing production table. I need to add a database-level UNIQUE constraint to that existing column while continuing to allow multiple existing NULL values.
CREATE UNIQUE INDEX through MCP execute_sql returns Blocked statement: Command not allowed. The Manage Tables UI only offers Rename/Delete for existing columns, and the Schema Diagram appears read-only.
What is the supported method for adding UNIQUE to an existing column without recreating the table or losing data?
Is ALTER TABLE bundle_material_events ADD CONSTRAINT uq_bme_business_fingerprint UNIQUE (business_fingerprint) supported through execute_sql, or is there another dashboard/API mechanism for this? Thanks

Founder Team
Riya_NoCodeBackend

Riya_NoCodeBackend

Sep 28, 2026

A: Hi,

You have three supported ways to add this UNIQUE constraint without recreating the table or losing any data:

Method 1: Using the "Run SQL" Button in the Dashboard (Direct)

1. Navigate to your database and open the "Edit Database" page.

2. In the top-right header, click the "Run SQL" button.

3. Run the following standard ALTER TABLE statement:

```sql
ALTER TABLE your_table_name
ADD CONSTRAINT uq_your_column UNIQUE (your_column_name);
```

4. Click "Run". The platform validates the query via a dry-run and applies the constraint immediately.

---

Method 2: Using "Ask AI" in the Dashboard

1. On the same "Edit Database" page, click the "Ask AI" button in the header.

2. Type in plain English:

> "Add a UNIQUE constraint to the [your_column_name] column on [your_table_name]."

3. Click "Generate & Apply". The AI will generate, validate, and execute the exact schema alteration automatically.

---

Method 3: Via MCP (`execute_sql`)

If you are working inside your AI editor (Cursor / Claude Desktop / Windsurf):

* The ALTER TABLE statement below is fully supported through `execute_sql`:

```sql
ALTER TABLE your_table_name
ADD CONSTRAINT uq_your_column UNIQUE (your_column_name);
```

* Why `CREATE UNIQUE INDEX` failed: The command validator's allowlist was matching `^CREATE INDEX` and missed the `UNIQUE` keyword between `CREATE` and `INDEX`.

* We have updated the validator so `CREATE UNIQUE INDEX` is now accepted as well.

---

Behavior with Existing NULL Values

Under MySQL / MariaDB (InnoDB), UNIQUE constraints natively permit unlimited NULL values because NULL != NULL.

* Multiple existing rows containing NULL will not violate the constraint or cause the operation to fail.
* Subsequent inserts or updates with NULL will continue to be allowed.
* Only duplicate non-null values will be blocked.
* No data will be lost.

Share
Helpful?
2
Log in to join the conversation

Verified purchaser

Perfect and a piece of cake, thank you!

Related questions
View product details