Delete a table relationship with a Jet SQL statement in Access

Source: Internet
Author: User

How do I build tables and relationships with Jet SQL's DDL statements?

Microsoft Access contains data Definition language (DDL) to create a delete table and relationships, which, of course, can be solved with DAO.

Here's an example:

Creates a table table1 with the DDL create TABLE, the primary key is an AutoNumber field, and the other is a text field with a length of 10.

CREATE TABLE table1 (ID counter constraint PrimaryKey primary key, MyText text (10))

To build a table table2 with two fields, the field ID is a long integer, and the field mytext is text

CREATE TABLE table2 (ID long, mytext text)

Establish a one-to-many relationship between Table1 and table2 with the following statement:

ALTER TABLE table2 ADD constraint relation1 foreign key ([id]) references table1 ([id])

Delete a relationship with the following statement:

ALTER TABLE table2 DROP constraint Relation1

Delete table1 with the following statement:

drop TABLE table1

Set a field as the primary key

ALTER TABLE 1 ALTER COLUMN [ID] counter constraint myprimarykey primary key

Add a field mysalary

ALTER TABLE AAA add column mysalary currency

Delete a field mysalary

ALTER TABLE AAA drop column Mysalary

How to run the above Jet SQL code, refer to the animated "How to run a Jet SQL code" in Http://access911.net, "How Flash painting Demonstrates how"

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.