Search code examples
alter-tableadvantage-database-server

Advantage Database Server 8.1 UNIQUE CONSTRAINT multiple columns


I am working on an Advantage Database Server 8.1 and I have created a new table. I want to add a unique constraint for the combination of 2 columns. I tried

ALTER TABLE TableName 
ADD CONSTRAINT ConstraintName 
UNIQUE (ColumnName1, ColumnName2)

but I get the error "ERROR IN SCRIPT: poQuery: Error 7200: AQE Error: State = 42000; NativeError = 2115; [Extended Systems][Advantage SQL Engine]Expected lexical element not found: You are missing the column names. -- Location of error in the SQL statement is: 33 (line: 2 column: 5)"


Solution

  • Ok the solution I found is:

    CREATE UNIQUE INDEX ConstraintName ON TableName (ColumnName1, ColumnName2);