建一个代理商表,之前有了一个order表,需要agent表里的order和order表里的ID(int)用外键联系,说in附近有错误,请帮忙看看create table agent
(
ID int primary key,
Name char(12) not null,
Area char(30) not null,
[In/Out] char(5) check ([In/Out] in ('In','Out')) default Out,
Price smallmoney not null,
[order] int,
Re text,
foreign key (order) reference [order](ID)
)
(
ID int primary key,
Name char(12) not null,
Area char(30) not null,
[In/Out] char(5) check ([In/Out] in ('In','Out')) default Out,
Price smallmoney not null,
[order] int,
Re text,
foreign key (order) reference [order](ID)
)
(
ID int primary key,
Name char(12) not null,
Area char(30) not null,
[In/Out] char(5) check ([In/Out] in ('In','Out')) default 'Out',
Price smallmoney not null,
[order] int,
Re text,
foreign key (order) reference [order](ID)
) 试试
ID int NOT NULL primary key, 2
default ('Out'),
[ COLLATE < collation_name > ]
[ [ DEFAULT constant_expression ]
| [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
]
[ ROWGUIDCOL]
[ < column_constraint > ] [ ...n ] < column_constraint > ::= [ CONSTRAINT constraint_name ]
{ [ NULL | NOT NULL ]
| [ { PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ]
[ WITH FILLFACTOR = fillfactor ]
[ON {filegroup | DEFAULT} ] ]
]
| [ [ FOREIGN KEY ]
REFERENCES ref_table [ ( ref_column ) ]
[ ON DELETE { CASCADE | NO ACTION } ]
[ ON UPDATE { CASCADE | NO ACTION } ]
[ NOT FOR REPLICATION ]
]
| CHECK [ NOT FOR REPLICATION ]
( logical_expression )
} 查帮助
(
ID int primary key,
Name char(12) not null,
Area char(30) not null,
[In/Out] char(5) check ([In/Out] in ('In','Out')) default 'Out',
Price smallmoney not null,
[order] int,
Re text,
foreign key (order) reference [order](ID)
)服务器: 消息 156,级别 15,状态 1,行 10
在关键字 'order' 附近有语法错误。
(
ID int primary key,
Name char(12) not null,
Area char(30) not null,
[In/Out] char(5) check ([In/Out] in ('In','Out')) default 'Out',
Price smallmoney not null,
[order] int foreign key ([order]) REFERENCES [order](ID) ,
Re text
)
[code=SQL]
CREATE TABLE [order](ID INT NOT NULL primary key)create table agent
(
ID int NOT NULL primary key,
Name char(12) not null,
Area char(30) not null,
[In/Out] char(5) check ([In/Out] in ('In','Out')) default 'Out',
Price smallmoney not null,
[order] int foreign key ([order]) REFERENCES [order](ID) ,
Re text
)
code]