CREATE TABLE

From SQLZOO
Revision as of 11:32, 17 July 2012 by Connor (Talk | contribs) (Created page with " <h1>CREATE TABLE</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...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

CREATE TABLE

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

games
yrcity
2004Athens
2008Beijing
schema:scott
 DROP TABLE games

The SELECT statement returns results from a table. With a WHERE clause only some rows are returned. This example shows the year that Athens hosted the Olympic games.

CREATE TABLE games
(yr   INT NOT NULL PRIMARY KEY
,city VARCHAR(20)
);
INSERT INTO games(yr,city) VALUES (2004,'Athens');
INSERT INTO games(yr,city) VALUES (2008,'Beijing');
SELECT * FROM games;
CREATE TABLE games
(yr   INT NOT NULL PRIMARY KEY
,city VARCHAR(20)
);
INSERT INTO games(yr,city) VALUES (2004,'Athens');
INSERT INTO games(yr,city) VALUES (2008,'Beijing');
SELECT * FROM games;

See also