SQL

Index Those SQL Tables

If you have growing sets of data, one of the best ways to speed up database performance is to make sure each column in larger tables is indexed. You can easily index a column following this syntax (using the name of your table in the place of tablename and the name of your column in the place of columnname):

ALTER TABLE tablename ADD INDEX (columnname);

So if you have a table called Customers and the following columns (as in the case of my Customers database from the previous exercises):

ID Site Contact Address City Zip Country

You would index them all as follows:

ALTER TABLE Customers ADD INDEX (ID);
ALTER TABLE Customers ADD INDEX (Site);
ALTER TABLE Customers ADD INDEX (Contact);
ALTER TABLE Customers ADD INDEX (Address);
ALTER TABLE Customers ADD INDEX (City);
ALTER TABLE Customers ADD INDEX (Zip);
ALTER TABLE Customers ADD INDEX (Country);