docs/versioned_docs/version-3.0.0-LTS/tooljet-db/constraints/primary-key.md
ToolJet Database supports both single field and composite primary keys.
<div style={{paddingTop:'24px'}}>When creating a new table, an id column with the serial data type is automatically generated to serve as the primary key. However, you can designate any other column as the primary key if desired. The primary key column can be of any supported data type except Boolean.
The constraints for the primary key column ensure the integrity and uniqueness of the primary key, which is essential for properly identifying and referencing records within the table. To create a single field primary key, follow these steps:
You have the option to convert an existing primary key column into a composite primary key, consisting of two or more columns. By utilizing a composite primary key, you can uniquely identify records based on multiple column values, providing greater flexibility and control over your data structure. To create a composite primary key, follow these steps:
After creating a table, you can designate any column as the primary key, provided it adheres to the required constraints. If the chosen column already contains data, the existing values must comply with the primary key constraints. However, you cannot update or modify the primary key of a target table if it is currently being referenced as a foreign key in any other source tables. To modify the primary key, follow these steps:
An existing primary key column can be deleted through the Edit Table panel. To delete the primary key column, follow these steps:
You cannot delete a Primary Key of a target table if it is being used as a foreign key in any source table(s).
</div>