Alex Alex - 2 months ago 23
SQL Question

Extending tables in SQL

How to add a column to the table:

create table table1 (id integer primary key, field1 text)


? The column would be
field2 text
and the value for existing rows in this column should be
value
.

Answer

For MySQL:

ALTER TABLE table1 ADD field2 text;
UPDATE table1 SET field2='value';