Difference between revisions of "CREATE TABLE"

From SQLZOO
Jump to: navigation, search
Line 14: Line 14:
 
In this example the column yr is the PRIMARY KEY:  
 
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 table1
(yr  INT NOT NULL PRIMARY KEY
+
(id int primary key,name varchar(20),city varchar(20),mobile numeric(10,0)
,city VARCHAR(20)
+
 
);
 
);
INSERT INTO games(yr,city) VALUES (2004,'Athens');
 
INSERT INTO games(yr,city) VALUES (2008,'Beijing');
 
SELECT * FROM games;
 
 
</source>
 
</source>
 
</div>
 
</div>

Revision as of 11:42, 7 March 2014

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 CREATE statement builds an empty table to hold rows. In this example the column yr is the PRIMARY KEY:

CREATE TABLE table1
(id INT PRIMARY KEY,name VARCHAR(20),city VARCHAR(20),mobile NUMERIC(10,0)
);

See also

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense