Difference between revisions of "UPDATE"
Jump to navigation
Jump to search
Line 37: | Line 37: | ||
INSERT INTO games VALUES (2008,'Beijing'); | INSERT INTO games VALUES (2008,'Beijing'); | ||
INSERT INTO games VALUES (2009,'London'); | INSERT INTO games VALUES (2009,'London'); | ||
+ | </source> | ||
+ | <source lang=sql class='setup'> | ||
CREATE TABLE number( | CREATE TABLE number( | ||
yr INTEGER, | yr INTEGER, |
Latest revision as of 15:42, 6 May 2014
UPDATE
The table games
shows the year and the city hosting the Olympic Games.
|
The table number
shows the year and the city hosting the Olympic Games.
|
schema:scott
DROP TABLE games
CREATE TABLE games(
yr INTEGER,
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 (2009,'London');
CREATE TABLE number(
yr INTEGER,
number VARCHAR(20));
INSERT INTO number VALUES (2000,'1');
INSERT INTO number VALUES (2004,'2');
INSERT INTO number VALUES (2008,'3');
INSERT INTO number VALUES (2009,'4');
The UPDATE statement can be used to change a values in rows that already exists. In this example we move the 2012 games from London to Paris.
UPDATE scott.games SET city='Paris' WHERE yr = 2012;
SELECT * FROM scott.games;
UPDATE games SET city='Paris' WHERE yr = 2012;
SELECT * FROM games;
See also