Difference between revisions of "ALTER TABLE ... ADD COLUMN"

From SQLZOO
Jump to navigation Jump to search
(Created page with "Add a column to a table <div class='ht'> <div class=params>schema:scott</div> <div> Naturally, all of the data in the table is lost when the table is dropped. Foreign Key ref...")
 
Line 3: Line 3:
<div class=params>schema:scott</div>
<div class=params>schema:scott</div>
<div>
<div>
Naturally, all of the data in the table is lost when the table is dropped.
This is in the SQL standard
 
<a href="http://sqlzoo.net/sql92.html#alter_table_statement">ALTER TABLE</a>
Foreign Key references can cause problems.
The term COLUMN is optional.
</div>
</div>



Revision as of 15:37, 12 July 2012

Add a column to a table

schema:scott

This is in the SQL standard <a href="http://sqlzoo.net/sql92.html#alter_table_statement">ALTER TABLE</a> The term COLUMN is optional.

DROP TABLE a
CREATE TABLE a(x INTEGER, y INTEGER);
INSERT INTO a VALUES (1,2);
ALTER TABLE a ADD COLUMN z INTEGER
ALTER TABLE a ADD z INTEGER