ALTER
ALTER TABLE
The table games
shows the year and the city hosting the Olympic Games.
yr | city |
---|---|
2004 | Athens |
2006 | Turin |
schema:scott
DROP TABLE games
CREATE TABLE games(
yr INTEGER PRIMARY KEY,
city VARCHAR(20));
INSERT INTO games VALUES (2004,'Athens');
INSERT INTO games VALUES (2006,'Turin');
The ALTER statement can be used to add a column. In this example the column season indicates if the games are winter or summer games.
SELECT * FROM scott.games;
ALTER TABLE games ADD season VARCHAR(6);
UPDATE games SET season = 'summer'
WHERE yr = 2004;
UPDATE games SET season = 'winter'
WHERE yr = 2006;
SELECT * FROM scott.games;
SELECT * FROM games;
ALTER TABLE games ADD season VARCHAR(6);
UPDATE games SET season = 'summer'
WHERE yr = 2004;
UPDATE games SET season = 'winter'
WHERE yr = 2006;
SELECT * FROM games;
See also
Language: | English • Deutsch |
---|