u013552383
寒初忆
2015-06-02 05:40
采纳率: 100%
浏览 1.7k

求教!下面的MySQL代码怎么改成sqlserver的?拜托拜托!

CREATE TABLE trade (
tradeid int NOT NULL PRIMARY KEY identity(17,1),
userid int NOT NULL,
tradetime datetime NOT NULL,
KEY "user_id_fk" ("userid"),
CONSTRAINT "user_id_fk" FOREIGN KEY ("userid") REFERENCES "userinfo" ("userid")
)

不知道怎么传图片,前面的我改过来了,还有后面两句的报错,倒数第二句“key”"userid",倒数第一句是"userid" "userid"

谢谢了,对数据库不太懂

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • guwei4037
    guwei4037 2015-06-02 05:49
    已采纳
     CREATE TABLE trade (
        tradeid int NOT NULL PRIMARY KEY identity(17,1),
        userid int NOT NULL,
        tradetime datetime NOT NULL,
        CONSTRAINT user_id_fk FOREIGN KEY (userid) REFERENCES userinfo(userid)
    )
    
    点赞 评论
  • Tiger_Zhao
    Tiger_Zhao 2015-06-02 05:52
        CREATE TABLE trade (
        tradeid int NOT NULL PRIMARY KEY identity(17,1),
        userid int NOT NULL,
        tradetime datetime NOT NULL,
        CONSTRAINT user_id_fk FOREIGN KEY (userid) REFERENCES userinfo(userid)
        )
    
    点赞 评论
  • edouardzyc
    edouardzyc 2015-06-02 05:52

    create table trade
    (
    tradeid int identity(1,1) not null primary key,
    userid int NOT NULL,
    tradetime datetime NOT NULL,
    )
    go

    alter table trade
    add
    constraint user_id_fk foreign key(userid) references userinfo(userid)
    go

    点赞 评论

相关推荐