Alter Table


--create table with the specified fields
create table aTable (id integer ,
name char(30),
surname char(30),
salary numeric);
--insert data to the coresponding fields
insert into aTable values(1,'John','John_Surname',234.554);
insert into aTable values(2,'Tim','Tim_Surname',3445.455);
insert into aTable values(3,'Gary','Gary_SurnameLane',33234.33445);
--select all the data from the table
select * from aTable;
--adds another field 'address' to the table schema
alter table aTable add column address char(30);
--selects all the data again
select * from aTable;
--update the table adding the addresses
update aTable set address = 'John Address' where id=1;
update aTable set address = 'Tim Address' where id=2;
update aTable set address = 'Gary Address' where id=3;
--selects all the data from the table
select * from aTable;



Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου