CRUD

房屋信息表
create table house
(
ids int identity primary key,--自增长列作为主键列
keywords varchar(50),--关键字
area varchar(50),--区域
housetype varchar(50),--房屋类型
renttype varchar(50),--租赁类型
price float,--价格
style varchar(50),--风格
memo text--描述
)
试题
create table shiti
(
ids int identity primary key,--自增长列作为主键列
title text,--题目内容
daan varchar(50)--题目答案
)
go
create table xuanxiang
(
ids int identity primary key,--自增长列作为主键列
tmcode int references shiti(ids), --tmcode与shiti表中的ids为外链关系
xxname varchar(50),--选项名称
xxcontent text--选项内容
)


create table friends
(
ids int identity primary key,
mecode varchar(50),
fcode varchar(50)
)


自增长列:如果你不确定表中确立谁为主键列,那可以将自增长列作为主键列
创建有外键关系表时,要先创建主表,再创建从表
关键字:
primary key 主键(一个表只能出现一次)
unique 唯一键(可以设置多个)
not null 非空
go 如果多条语句要一起执行,那么每条语句之后需要加go
reference 外键关系(引用)
identity 自增长

原文地址:https://www.cnblogs.com/blueteasama/p/5809698.html