How to delete a table relationship with Jet SQL statement in Access?

zhaozj2021-02-16  45

How to delete a table relationship with Jet SQL statement in Access?

How to build a table and relationship with Jet SQL DDL statement? Microsoft's Access contains Data Definition Language (DDL) to create delete tables and relationships, of course, this can also be solved with DAO. The following is an example: establish a table table1 with DDL's CREATE TABLE, the primary key is the automatic number field, and the other field is the text field of the length is 10.

Create Table Table1 (ID Counter Constraint Primarykey Primary Key, Mytext Text (10)) Built another table table2, field ID is long integer, field mytext is text

Create Table Table2 (ID long, mytext text) Establish a pair of relationships with Table1 and Table2 with the following statement:

ALTER TABLE TABLE2 Add Constraint Relation1 Foreign Key ([ID]) References Table1 ([ID]) Delete relationship with the following statement:

ALTER TABLE TABLE2 DROP CONSTRAINT RELATION1 Remove Table1 Use the following statement:

DROP TABLE TABLE1 Sets a field as the primary key

Alter Table Table 1 Alter Column [ID] Counter Constraint MyPrimaryKey Primary Key Add a field mysalary

ALTER TABLE AAA Add ColumnLay Currency Delete a Field Mysalary

Alter Table AAA Drop Column Mysalary How to run the above Jet SQL code, please refer to the animation "How to Demonstrate" in Http://access911.net "How to Run a Jet SQL Code"

http://www.access911.net webmaster collection

转载请注明原文地址:https://www.9cbs.com/read-24500.html

New Post(0)