Defining a Unique Key

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Tutorials > "ZooDB" Database > Defining Constraints >

Defining a Unique Key

By defining a unique key, you can prevent the user from entering duplicate data into a column. In our zoo database, you will define a unique key on the LatinName column of table tblAnimalTypes. This way, each name can be added to the table only once.

 

 

To define a unique key on a column:

1.In the Online Browser, right-click the table tblAnimalTypes and select Design Editor | Show in new Design Editor from the context menu.
2.In the table design, right-click the column LatinName and select Make Unique key from the context menu.

design_create-unique-key

A unique key is created in the design, having the name <generated>, and the entry is selected for editing.

3.Optionally, change the key name from <generated> to "UK_LatinName" and press Enter. If you leave the name as <generated>, the key name will be automatically generated by the database.

design_edit-UK-name

4.In the Database Structure Change Script window, click the Execute Change Script ic_execute-sql button to execute the change script and to commit the new unique key to the database.

© 2019 Altova GmbH