> For the complete documentation index, see [llms.txt](https://docs.docbits.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docbits.com/administration-and-setup/settings/global-settings/document-types/table-columns/adding-a-new-column.md).

# Adding a new Column

## Adding a new column to an existing table requires careful planning and execution to ensure that data integrity is maintained and application requirements are met.

<figure><img src="/files/voFjyXxpnm7gWVv7P2w7" alt=""><figcaption><p>Settings: Document Types</p></figcaption></figure>

<figure><img src="/files/O0qgFf8BhK9yn6peWU6g" alt=""><figcaption><p>Table Columns</p></figcaption></figure>

**Here are detailed steps to add a new column:**

<figure><img src="/files/6hApYkV2RMRS9tSv6vp5" alt=""><figcaption></figcaption></figure>

**Requirements analysis:**

* Review your application's requirements and identify the purpose of the new column. What type of data will be stored? How will this column be used in the application?

<figure><img src="/files/xHxPgTVhxwBBjjKoNBXQ" alt="" width="375"><figcaption><p>Add new table column</p></figcaption></figure>

**Choosing the right column type:**

* Choose the most appropriate column type based on the data that will be stored in the column. This can be AMOUNT for amount, STRING for strings, DATE for dates, etc.
* Choosing the right column type is important to ensure data integrity and use storage space efficiently.

<figure><img src="/files/6vm71e5JovCfooN57iyL" alt="" width="375"><figcaption></figcaption></figure>

**Choosing the right table:**

* To select the correct column type in a particular table, such as the invoice table, it is important to consider the specific requirements of the data to be stored in that table.

<figure><img src="/files/jKY0vCNetkhdOKSTd7Jz" alt="" width="375"><figcaption></figcaption></figure>

**Deciding on column necessity:**

* Consider whether the new column is required or whether it should allow NULL values. If the column is mandatory, it should be marked as NOT NULL to ensure that important data is not missing.
* Also consider whether the column may become a required field for your application in the future.

**Database backup:**

* Before adding the new column, make a backup of your database to ensure that you have a working version to fall back on in case of any issues.

**Executing the SQL statement:**

* Use the ALTER TABLE SQL statement to add the new column. The exact syntax depends on the database platform you are using, but in general the SQL statement looks like this:

  <figure><img src="/files/7raA74rA7FnRDu93RlY4" alt=""><figcaption></figcaption></figure>

  Replace table\_name with the name of your table, new\_column\_name with the name of the new column, and data\_type with the column type you selected. The \[NOT NULL] keyword indicates whether the column is mandatory.

**Testing and validating:**

* After the new column is added, thoroughly verify that your application is working properly. Run tests to ensure that data is stored and retrieved correctly and that the new column is working as expected.

By carefully following these steps, you can successfully and effectively add a new column to your database table, choosing the correct column type and ensuring that the column is required when it is required.


---

# 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:

```
GET https://docs.docbits.com/administration-and-setup/settings/global-settings/document-types/table-columns/adding-a-new-column.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
