2016-10-10 5 views
0

は私のコードは、私は複数のテーブルを作成しようとしている、次のとおりです。Microsoft Accessでテーブル構文エラーを作成しますか?ここ

Create Table Order_t 
(
Id AutoIncrement Not Null, 
OrderDate DateTime Not Null, 
CustId Int Not Null, 
Primary Key(Id), 
Foreign Key(CustId) References Customer_t(Id) 
(; 
Create Table PersonRole_t 
(
PersonRoleID Autoincrement Not Null, 
Person_ID int Not Null, 
Primary Key(PersonRoleID, Person_ID), 
Foreign Key(Person_ID) References Person_T(Person_ID) 
(; 
Create Table Product_t 
(
Id Text(10) Not Null, 
Name Text(30) Not Null, 
Description Text(30), 
Finish Text(30), 
UnitPrice Currency Not Null, 
Primary Key(Id) 
) ; 

私はMicrosoft Accessでそれを実行するたびに、私は(それがPersonRole_Tのテーブル定義を強調して)CREATE TABLE文でエラーが発生します。何をすべきかわからず、SQLでは初めてです。 Person_IDのキーを持つ代わりにOPEN括弧

Create Table Order_t 
(
Id AutoIncrement Not Null, 
OrderDate DateTime Not Null, 
CustId Int Not Null, 
Primary Key(Id), 
Foreign Key(CustId) References Customer_t(Id) 
); -- Not (; 

Create Table PersonRole_t 
(
PersonRoleID Autoincrement Not Null, 
Person_ID int Not Null, 
Primary Key(PersonRoleID, Person_ID), 
Foreign Key(Person_ID) References Person_T(Person_ID) 
); -- Not (; 

答えて

1

使用CLOSE括弧テーブルPerson_TReferences Person_T(Person_ID)文が実行できる前に存在する必要があります。あなたの命名規則に基づいて、私は文がむしろReferences Person_T(Id)であるべきだと思います。

データ要素の名前がテーブル/ビューの位置に応じて変更されないように命名規則を変更することを検討してください。また、接尾辞_tが迷惑にならないかどうかを検討してください。

@Prdpのポイントが近い括弧も有効です。

+0

OPの明白な点を述べるだけで、Access SQL構文はコメントをサポートしていないので、実行時には不要な部分を削除する必要があります。 – onedaywhen

関連する問題