Pregunta

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.

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top