Tsql语句

Tsql语句:

选中数据库 -> 点开查询 -> 创建查询 -> 输入代码 -> 运行

表中刷新后显示

 

创建表

 

create table shangpin(
  code int primary key,
      name varchar(50) not null,
      price float,
      pinpai int,
      foreign key(pinpai) references pinpai(ids)
)

 

create table pinpai(
      ids int auto_increment primary key,
      name varchar(50)              
)

 

 

 

效果图:

 

逻辑:

主表一定是在从表之前的,从表只能和主表的主键有关系。

 

注释语法:#

 

关键字:

主键:primary key

非空:not null

自增长列:auto_increment

 外键:foreign key

posted @ 2018-01-08 16:50  桃花灬仙人  阅读(241)  评论(0编辑  收藏  举报