A unique index containing only single column must exist on the specified table before the fulltext index is created. If the unique Index created on the partitioned table does not include partition Column,sql Server throws an error Message, the script is as follows
INDEX uq_idx_indexnameon schema_name.table_name ([col1]) with(data_compression =row);
Error description:column ' Createddatekey ' is partitioning Column of the index ' Uq_idx_indexname '. Partition columns for a unique index must is a subset of the index key.
If you want to create a Aligned unique index on partitioned table, the partition column must be index Key.
CREATE UNIQUE nonclustered INDEX Uq_idx_indexname on schema_name.table_name ([col1],[Createddatekey ])with (data_compression=row);
You can use the ON clause to specify the filegroup of the index store so that the unique index created by SQL Server on partitioned table is no-aligned.
CREATE UNIQUE nonclustered INDEX Uq_idx_indexname on schema_name.table_name ([col1],) with (Data_compression=row) on [Primary];
Appendix:create Index Syntax
CREATE [UNIQUE] [CLUSTERED | Nonclustered] INDEXindex_name on <Object>(column [ASC | DESC] [,... N] ) [INCLUDE (column_name [,... n] ) ] [WHERE <filter_predicate>] [With (<relational_index_option> [,... n] ) ] [On {partition_scheme_name (column_name) | filegroup_name | default}]
On filegroup_name
Creates the specified index on the specified filegroup. If no location is specified and the table or view are not partitioned, the index uses the same filegroup as the underlying Table or view. The filegroup must already exist.
partitioned Indexes
Partitioned indexes is created and maintained in a similar manner to partitioned tables, but like ordinary indexes, they is handled as separate database objects. You can have a partitioned index on a table so is not partitioned, and can has a nonpartitioned index on a table th At is partitioned.
If you is creating an index on a partitioned table, and does not specify a filegroup in which to place the index, the index is partitioned in the same manner as the underlying table. This was because indexes, by default, was placed on the same filegroups as their underlying tables, and for a partitioned T Able in the same partition scheme, that uses the same partitioning columns. When the index uses the same partition scheme and partitioning column as the table, the index was aligned with The table.
When partitioning a non-unique, clustered index, the Database Engine by default adds any partitioning columns to the list of clustered index keys, if not already specified.
Aligned Index
An index which is built on the same partition scheme as its corresponding table. When a table and its indexes is in alignment, the SQL Server can switch partitions quickly and efficiently while maintaining The partition structure of both the table and its indexes. An index does not has to participate in the same named partition function to is aligned with its base table. However, the partition function of the index and the base table must is essentially the same, in that 1) the arguments of The partition functions has the same data type, 2) they define the same number of partitions, and 3) they define the same Boundary values for partitions.
nonaligned Index
An index partitioned independently from its corresponding table. That's, the index has a different partition scheme or was placed on a separate filegroup from the base table. Designing an nonaligned partitioned index can is useful in the following cases:
-
The base table has not been partitioned.
-
The index key is a unique and it does not contain the partitioning column of the table.
-
You want the base table to participate in collocated joins with more tables using different join columns.
Reference doc:
CREATE INDEX (Transact-SQL)
Partitioned Tables and Indexes
Full-text Indexes in partitioned tables
If The unique index does not contain the partitioning column then SQL Server would has the to check for duplicate in any part Itions for each insert or update of the row (e.g. partition to Columns "a" and you with the unique index "B", then (b ) rows and (3,2) could is in different partitions). This would leads to very inefficient maintenance of uniquness and that's the primary reason why SQL Server 2005 enforces t He partitioning key to being contained in the unique key (because then the "duplicates" would always be in the same partition) .
You can create a unique partitioned index by partitioning it on the key, or create non-partitioned unique index regardless I F and how the table is partitioned. This is the creating of the index in a "separate" Filegroup-such index was not partitioned. If you don ' t specify filegroup, the index'll be (by default) partitioned exactly as the table.
Create a unique Index on a partitioned table