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

Source: Internet
Author: User
access| statement
How do you delete a table relationship with a Jet SQL statement in Access?



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"
Http://www.access911.net Webmaster Collection

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.