20.07.2013 Views

Beginning SQL

Beginning SQL

Beginning SQL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The results are ordered because, by default, the index orders results in ascending order. The default<br />

order is based on the order in which you list the columns in the index definition’s SELECT statement. To<br />

delete the index, you need to use the DROP INDEX statement, specifying the index name in the statement.<br />

Note that in some RDBMSs, such as MS <strong>SQL</strong> Server, you need to specify the table name in addition<br />

to the index name. So, the <strong>SQL</strong> to drop the index just created in MS <strong>SQL</strong> Server is as follows:<br />

DROP INDEX MemberDetails.member_name_indx;<br />

In IBM DB2 and Oracle, the DROP INDEX statement simply requires the index name without the table<br />

name prefixed:<br />

DROP INDEX member_name_indx;<br />

In My<strong>SQL</strong>, the code to drop the index is as follows:<br />

ALTER TABLE MemberDetails<br />

DROP INDEX member_name_indx;<br />

MS Access has yet another way of dropping the index:<br />

DROP INDEX member_name_indx ON MemberDetails;<br />

After dropping the index, run the same SELECT statement:<br />

SELECT FirstName, LastName<br />

FROM MemberDetails;<br />

You find that the results are no longer necessarily in order:<br />

FirstName LastName<br />

Katie Smith<br />

Susie Simons<br />

John Jackson<br />

Steve Gee<br />

John Jones<br />

Jenny Jones<br />

Jack Johnson<br />

Seymour Botts<br />

Jamie Hills<br />

Stuart Dales<br />

William Doors<br />

Doris Night<br />

Catherine Hawthorn<br />

Advanced Database Design<br />

141

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!