Altova DatabaseSpy 2024 Professional Edition

By defining a unique key, you can prevent duplicate data from being entered 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.Open the "ZooDB" project created previously and double-click the dbs_ic_connected ZooDBConnect data source to connect to it.

2.In the Online Browser, right-click the table tblAnimalTypes and select Design Editor | Show in new Design Editor from the context menu.

3.In the table design, right-click the column LatinName and select Make Unique key from the context menu.


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

4.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.


5.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.

© 2017-2023 Altova GmbH