We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Add index to table

Medium Priority
301 Views
Last Modified: 2012-05-11
I have a table with a primary key.
How would I add an index to an additional column?
Comment
Watch Question

Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
you create another index, normally on just that column.

what is the exact issue you have?
There are normally two types of indexes - Clustered and non-Clustered. Primary keys normally create clustered index. So which type of index do you want to create on another column?

If you want to create nonclustered index then you can simply use

CREATE INDEX INDEX_NAME
on TABLENAME (COLUMN NAME)
Larry Bristersr. Developer

Author

Commented:
angelIII:

I have a table that stores our media "mail history" ...actual addresses for bulk mail

the mailID is the primary key

Ive been asked to add an index on AddrID column
Neil RussellTechnical Development Lead

Commented:
So if your table is called MailHistory you would use

CREATE INDEX idxAddrID
on MailHistory (AddrID)
Larry Bristersr. Developer

Author

Commented:
malikirfan28: was first and Neilsr: was precise

Any problems with a 350/150 split?
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Alpesh PatelSolution Architect at TCS (SAFe®Agilist, TOGAF® Foundation, PSM I®, MCP, MCSD)
CERTIFIED EXPERT

Commented:
Hey you can create a non cluster index on other than primary key. Same as cluster index

Create index Indexname on Table (Columnname)
Larry Bristersr. Developer

Author

Commented:
malikirfan28
You have a  valid point
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.