Use JetSQL statements in Access to delete table relationships

Source: Internet
Author: User
How to Use the ddl Statement of jetsql to establish tables and relationships? Microsoft's Access includes DataDefinitionLanguage (DDL) to create and Delete tables and relationships. Of course, this can also be solved using DAO. The following is an example: Use CreateTable of 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. CRES

How to Use the ddl Statement of jetsql to establish tables and relationships? Microsoft's Access includes DataDefinitionLanguage (DDL) to create and Delete tables and relationships. Of course, this can also be solved using DAO. The following is an example: Use CreateTable of 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. CRES

How to Use the ddl Statement of jetsql to establish tables and relationships?

Microsoft's Access includes DataDefinitionLanguage (DDL) to create and Delete tables and relationships. Of course, this can also be solved using DAO.

The following is an example:

Use CreateTable of DDL to create a table Table1. The primary key is an automatic number field, and the other is a text field with a length of 10.

CREATETABLETable1 (IdCOUNTERCONSTRAINTPrimaryKeyPRIMARYKEY, MyTextTEXT (10 ))

Create a table named Table2 that contains two fields. The field id is a long integer and the field MyText is text.

CREATETABLETable2 (IdLONG, MyTextTEXT)

Use the following statement to create a one-to-multiple relationship between Table1 and Table2:

Altertable2addconstraintrelation1foreignkey ([Id]) REFERENCESTable1 ([Id])

Use the following statement to delete a link:

ALTERTABLETable2DROPCONSTRAINTRelation1

To delete table 1, use the following statement:

DROPTABLETable1

Set a field as the primary key

ALTERTABLE Table 1 ALTERCOLUMN [id] COUNTERCONSTRAINTMyPrimaryKeyPRIMARYKEY

Add a field MySalary

AltertableAAAaddCOLUMNMySalaryCURRENCY

Delete a field MySalary

AltertableAAAdropCOLUMNMySalary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.