How to add constraint for a field in a table that should only contain unique values in SAP?
The syntax for creating a unique constraint using an ALTER TABLE statement in SQL Server is: ALTER TABLE table_name ADD CONSTRAINT constraint_name UNIQUE (column1, column2, ... column_n); table_name.
The syntax for creating a unique constraint using an ALTER TABLE statement in MySQL is: ALTER TABLE table_name ADD CONSTRAINT constraint_name UNIQUE (column1, column2, ... column_n); table_name.
To modify a unique constraintIn the Object Explorer, right-click the table containing the unique constraint and select Design. On the Table Designer menu, click Indexes/Keys.... In the Indexes/Keys dialog box, under Selected Primary/Unique Key or Index, select the constraint you wish to edit.
Both the UNIQUE and PRIMARY KEY constraints provide a guarantee for uniqueness for a column or set of columns. A PRIMARY KEY constraint automatically has a UNIQUE constraint. However, you can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table.
So, in your table; you wish there weren't any NON-KEY attributes, right?
If you want to do it using code...
ALTER TABLE dbo.MyTable ADD CONSTRAINT MyTable_Code_Name_UniqueKey UNIQUE (Code, Name)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With