> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-default-duplicate-values.md).

# INSERT - Default & Duplicate Values

## Default Values

If the [SQL\_MODE](/docs/server/server-management/variables-and-modes/sql_mode.md) contains `STRICT_TRANS_TABLES` and you are [inserting](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert.md) into a transactional table (like InnoDB), or if the SQL\_MODE contains `STRICT_ALL_TABLES`, all `NOT NULL` columns which do not have a `DEFAULT` value (and are not [AUTO\_INCREMENT](/docs/server/reference/data-types/auto_increment.md)) must be explicitly referenced in `INSERT` statements. If not, an error like this is produced:

```
ERROR 1364 (HY000): Field 'col' doesn't have a default value
```

In all other cases, if a `NOT NULL` column without a `DEFAULT` value is not referenced, an empty value will be inserted (for example, 0 for `INTEGER` columns and '' for `CHAR` columns). See [NULL Values in MariaDB:Inserting](/docs/server/reference/data-types/null-values.md) for examples.

If a `NOT NULL` column having a `DEFAULT` value is not referenced, `NULL` will be inserted.

If a `NULL` column having a `DEFAULT` value is not referenced, its default value will be inserted. It is also possible to explicitly assign the default value using the `DEFAULT` keyword or the [DEFAULT()](/docs/server/reference/sql-functions/secondary-functions/information-functions/default.md) function.

If the `DEFAULT` keyword is used but the column does not have a `DEFAULT` value, an error like this is produced:

```
ERROR 1364 (HY000): Field 'col' doesn't have a default value
```

## Duplicate Values

By default, if you try to insert a duplicate row and there is a `UNIQUE` index, `INSERT` stops and an error like this is produced:

```
ERROR 1062 (23000): Duplicate entry 'dup_value' for key 'col'
```

To handle duplicates you can use the [IGNORE](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/ignore.md) clause, [INSERT ON DUPLICATE KEY UPDATE](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-on-duplicate-key-update.md) or the [REPLACE](/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/replace.md) statement. Note that the IGNORE and DELAYED options are ignored when you use [ON DUPLICATE KEY UPDATE](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-on-duplicate-key-update.md).

## See Also

* [INSERT](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert.md)
* [INSERT DELAYED](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-delayed.md)
* [INSERT SELECT](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-select.md)
* [HIGH\_PRIORITY and LOW\_PRIORITY](/docs/server/reference/sql-statements/data-manipulation/changing-deleting-data/high_priority-and-low_priority.md)
* [Concurrent Inserts](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/concurrent-inserts.md)
* [INSERT IGNORE](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-ignore.md)
* [INSERT ON DUPLICATE KEY UPDATE](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-on-duplicate-key-update.md)

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-default-duplicate-values.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
