Difference between revisions of "CREATE INDEX"

From SQLZOO
Jump to: navigation, search
(Created page with " <h1>CREATE INDEX</h1> <p>The table <code>games</code> shows the year and the city hosting the Olympic Games.</p> <table> <caption align='center'>games</caption> <tr><th align...")
 
Line 23: Line 23:
 
When you create an index you make it faster to find a particular row.  
 
When you create an index you make it faster to find a particular row.  
 
You can also make the JOIN operator faster.   
 
You can also make the JOIN operator faster.   
<source lang='sql' class='def e-oracle'>
 
CREATE INDEX gamesIdx ON games(city,yr);
 
SELECT yr, city FROM scott.games
 
</source>
 
 
<source lang='sql' class='def'>
 
<source lang='sql' class='def'>
 
CREATE INDEX gamesIdx ON games(city,yr);
 
CREATE INDEX gamesIdx ON games(city,yr);

Revision as of 08:37, 7 March 2014

CREATE INDEX

The table games shows the year and the city hosting the Olympic Games.

games
yrcity
2000Sydney
2004Athens
2008Beijing
2012London
schema:scott
 DROP TABLE games
 CREATE TABLE games(
  yr INTEGER PRIMARY KEY,
  city VARCHAR(20));
INSERT INTO games VALUES (2000,'Sydney');
INSERT INTO games VALUES (2004,'Athens');
INSERT INTO games VALUES (2008,'Beijing');
INSERT INTO games VALUES (2012,'London');

When you create an index you make it faster to find a particular row. You can also make the JOIN operator faster.

CREATE INDEX gamesIdx ON games(city,yr);
SELECT yr, city FROM games

See also

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense