Microsoft's Access includes DataDefinitionLanguage (DDL) to create and Delete tables and relationships. Of course, this can also be solved using DAO.
Microsoft's Access includes Data Definition Language (DDL) to create and Delete tables and relationships. Of course, this can also be solved using DAO.
The following is an example:
Create Table with DDL to Create a Table Table1. The primary key is an automatically numbered field, and the other is a text field with a length of 10.
The Code is as follows:
Create table Table1 (Id counter constraint PrimaryKey primary key, MyText TEXT (10 ))
Create a table named Table2 that contains two fields. The field id is a long integer and the field MyText is text.
The Code is as follows:
Create table Table2 (Id LONG, MyText TEXT)
Use the following statement to create a one-to-multiple relationship between Table1 and Table2, cascade update, and cascade deletion:
The Code is as follows:
Alter table Table2 add constraint Relation1 foreign key ([Id]) REFERENCES Table1 ([Id]) ON UPDATE CASCADE ON DELETE CASCADE
Use the following statement to delete a link:
The Code is as follows:
Alter table Table2 drop constraint Relation1
To delete table 1, use the following statement:
The Code is as follows:
Drop table Table1
Set a field as the primary key
The Code is as follows:
Alter table 1 alter column [id] counter constraint MyPrimaryKey PRIMARY KEY
Add a field MySalary
The Code is as follows:
Alter table AAA add COLUMN MySalary CURRENCY
Delete a field MySalary
The Code is as follows:
Alter table AAA drop COLUMN MySalary