Creating indexes on encrypted columns

You can create an index on an encrypted column if the encryption key has been specified without any initialization vector or random padding. An error occurs if you execute create index on an encrypted column that has an initialization vector or random padding. Indexes on encrypted columns are useful for equality and non-equality matches, but not for range searches or ordering.

NoteYou cannot use an encrypted column in an expression for a functional index.

In the following example, cc_key specifies encryption without using an initialization vector or padding. This allows an index to be built on any column encrypted with cc_key:

create encryption key cc_key for AES
	 		 with init_vector null

create table customer(custid int,
	 		 creditcard varchar(16) encrypt with cc_key)

create index cust_idx on customer(creditcard)