문제

What is the syntax to add a Primary Key to an existing Production database? I have inherited a database with no Primary Keys set for anything, and I need a primary key on each table to use my ORM for an application.

I tried googling to no avail, Advantage's documentation isn't the best in the world.

도움이 되었습니까?

해결책

Tables in free connections don't support a primary key. (They do support unique indexes however.)

Tables in dictionaries support primary keys by the table property TABLE_PRIMARY_KEY.

http://devzone.advantagedatabase.com/dz/webhelp/Advantage11.1/master_sp_modifytableproperty.htm

EXECUTE PROCEDURE sp_ModifyTableProperty(
    'TableName'
  , 'TABLE_PRIMARY_KEY'
  , 'IndexName'
  , 'RETURN_ERROR'
  , NULL
)

You have to add a unique index using the CREATE UNIQUE INDEX statement first.

CREATE UNIQUE INDEX IndexName ON TableName (ColumnName)

http://devzone.advantagedatabase.com/dz/webhelp/Advantage11.1/master_create_index.htm

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top