Week2 - Data Definition Language / Design

The questions can come in any order, so make sure you are selecting right option for all questions.

1. Write a query to create 'building' table.
create table building(
id integer not null,
owner_name varchar(100) not null,
address varchar(100) not null,
building_type_id integer not null,
contact_number varchar(100) not null,
email_address varchar(100)
)
2. Write a query to change the column name 'email_address' to 'email' in the building table.
alter table building rename column email_address to email;
3. Write a query to add new column "description" of type varchar(255) add not null constraint to building table.
alter table building add description varchar(255) NOT NULL;
4. Write a query to remove the column 'address' from the 'building' table.
alter table building drop column address;
5. Write a query to change the type of field 'owner_name' in the 'building' table to varchar(500).
alter table building modify owner_name varchar(500);
6. Write a query to drop table 'building'.
drop table building;

2 comments

  1. Anonymous
    none of these are working
    1. Anonymous
      you have to run the query in 1st question every time you open the module