CREATE UNIQUE INDEX gdCust_idx ON GoodCustomers(CustomerID, CustomerName)
请问如上代码中,这时的index是CustomerID+CustomerName,还是说CustomerID和CustomerName各自都有自己的index?

解决方案 »

  1.   


    --请问如上代码中,这时的index是CustomerID+CustomerName,还是说CustomerID和CustomerName各自都有自己的index?
    是CustomerID+CustomerName的联合索引,且是唯一索引
      

  2.   

    唯一索引:一种索引,不允许具有索引值相同的行,从而禁止重复的索引或键值。系统在创建该索引时检查是否有重复的键值,并在每次使用 INSERT 或 UPDATE 语句添加数据时进行检查。
    CREATE UNIQUE INDEX gdCust_idx ON GoodCustomers(CustomerID, CustomerName)创建唯一联合索引
      

  3.   

    多谢楼上各位的热心解答,原来是组合索引,那么请问如果要分别的两个列设置索引的话,语法是这样的么?
    CREATE UNIQUE INDEX gdCust_idx ON GoodCustomers(CustomerID), Unique Index gdCust_idx1 On GoodCustomers(CustomerName)
      

  4.   

    分开成两个索引,有可能不是唯一的,所以不能确定是否能加UNIQUE(唯一)关键字。
    语法如下: CREATE INDEX gdCust_idx_cn ON GoodCustomers( CustomerName)
    go
    CREATE INDEX gdCust_idx_cid ON GoodCustomers(CustomerID)