Difference between revisions of "CREATE TABLE"
(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...") |
m (Reverted edits by 117.212.90.88 (talk) to last revision by Andr3w) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 11: | Line 11: | ||
<div class=params>schema:scott</div> | <div class=params>schema:scott</div> | ||
<source lang=sql class='tidy'> DROP TABLE games</source> | <source lang=sql class='tidy'> DROP TABLE games</source> | ||
− | The | + | The CREATE statement builds an empty table to hold rows. |
− | + | In this example the column yr is the PRIMARY KEY: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<source lang='sql' class='def'> | <source lang='sql' class='def'> | ||
CREATE TABLE games | CREATE TABLE games |
Revision as of 12:34, 9 March 2014
CREATE TABLE
The table games
shows the year and the city hosting the Olympic Games.
yr | city |
---|---|
2004 | Athens |
2008 | Beijing |
schema:scott
DROP TABLE games
The CREATE statement builds an empty table to hold rows. In this example the column yr is the PRIMARY KEY:
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