HandsOn Deleting Tables and Constraints Using the Access User Interface

This hands-on requires that you have the tblBookOrders and tblAwards tables created in Hands-On 20-1 and 20-2.

1. In the Database window, select the Queries object and click the New button.

2. In the New Query dialog box, select Design View and click OK.

3. In the Show Table dialog box, click the Close button.

4. Choose Query | SQL Specific | Data Definition from the menu bar.

Part III

5. In the Data Definition Query window, enter the statement shown in Figure 20-4.

Ê1 OuervlData DeBWBCniQuerv - X

! L op Tâble tblBiiokOrderaj

Figure 20-4: To delete a table that contains ä I a CHECK constraint, type the DROP TABLE

statement in the Data Definition Query

6. To run the Data Definition Query, choose Query | Run.

Note that a table must be closed before it can be deleted. If you don't want to delete the table but need to remove the constraint from a table, use the following syntax:

ALTER TABLE table_name DROP CONSTRAINT constraint_name To remove a constraint, you must know its name.

7. To delete the constraint from the tblAwards table, open the Data Definition Query window and type the statement shown in Figure 20-5.

É1 Q.uery1 ; Ööld Definition Query lALTER TABLE tbïinanls DROP CONSTRAINT FrtraToj

Figure 20-5: To remove a table constraint use the DROP CONSTRAINT statement with ALTER TABLE.

Note: Before using ALTER TABLE, it is a good idea to make a backup copy of the table.

8. Choose Query | Run to execute the statement to delete the constraint.

9. On your own, delete the tblSupplies table using the Data Definition Query.

0 0

Post a comment