function db_add_unique_key

7.x database.inc db_add_unique_key($table, $name, $fields)
6.x database.pgsql.inc db_add_unique_key(&$ret, $table, $name, $fields)
6.x database.mysql-common.inc db_add_unique_key(&$ret, $table, $name, $fields)

Add a unique key.

Parameters

$ret: Array to which query results will be added.

$table: The table to be altered.

$name: The name of the key.

$fields: An array of field names.

Related topics

6 calls to db_add_unique_key()
system_update_6019 in drupal-6.x/modules/system/system.install
Reconcile small differences in the previous, manually created mysql and pgsql schemas so they are the same and can be represented by a single schema structure.
system_update_6032 in drupal-6.x/modules/system/system.install
profile_fields.name used to be nullable but is part of a unique key and so shouldn't be.
system_update_6036 in drupal-6.x/modules/system/system.install
Change the search schema and indexing.
system_update_6043 in drupal-6.x/modules/system/system.install
Update table indices to make them more rational and useful.
system_update_6055 in drupal-6.x/modules/system/system.install
Improve indexes on the {url_alias} table.

... See full list

File

drupal-6.x/includes/database.mysql-common.inc, line 410
Functions shared between mysql and mysqli database engines.

Code

function db_add_unique_key(&$ret, $table, $name, $fields) {
  $ret[] = update_sql('ALTER TABLE {' . $table . '} ADD UNIQUE KEY ' .
    $name . ' (' . _db_create_key_sql($fields) . ')');
}