Practice questions:
1. Write a CREATE TABLE statement to create a table Addressbook (address book) that contains the items listed in Table 1-A, and set primary key constraints for the regist_no (registration number) column
CREATE TABLE Addressbook (
regist_no int not null,
a_name varchar(128) not null,
address varchar(256) not null,
tel_no varchar(10),
mail_address char(20),
PRIMARY KEY(regist_no));
2. Suppose you forgot to add the following column postal_code (postal code) when creating the Addressbook table in Exercise 1.1, please add this column to the Addressbook table.
Column name: postal_code
Data type: fixed-length string type (length is 8)
Constraint: cannot be NULL
ALTER TABLE Addressbook add (postal_code char(10) not null);
3. Write a SQL statement to delete the Addressbook table.
DROP TABLE Addressbook;
4. Write SQL statements to restore the deleted Addressbook table.
START TRANSACTION;
DROP TABLE Addressbook;
ROLLBACK;