In this third part to a series on beginning SQL, you'll learn how to use SQL statements to manipulate entire tables: to join them, alter them, and even delete them. It's all part of keeping a firm grip on your databases. Keep reading to learn more.
Databases, like programmers, can get big and bloated. When you get them to try and give you something, it takes them forever. If they get too big, they simply freeze up and then how will you get your data?
Well the solution is simple: create an index. An index cuts the time it takes to run a query by, you guessed it...indexing the data held within the database.
CREATE UNIQUE INDEX MyIndex
ON EMPLOYEE (FirstName);
The above code creates a UNIQUE INDEX called MyIndex. It indexes the data based on the FirstName column found within the EMPLOYEE table. A UNIQUE INDEX simply means that it allows no duplicate records.
For a SIMPLE INDEX (an index that allows duplicates) use the following code:
CREATE INDEX MyIndex
ON EMPLOYEE (FirstName);
If you wanted to add a sort feature you could do that as well.
CREATE UNIQUE INDEX MyIndex
ON EMPLOYEE (FirstName DESC);
And if you want to index more than one column, that too is possible.