倾心于你

导航

 

建数据库

use master
go
if exists(select * from sys.databases where name='Test')
drop database Test
go
create database Test
go--批处理
use Test
go
create table Info
(
id int primary key identity(10000,1),
name varchar(10) not null,
sex char(2) check(sex='男' or sex='女') default('男') not null,--默认'男'
tell char(11) unique not null,--唯一
)
create table Score
(
id int primary key identity(1,1),
sid int references Info(id) not null,
subject varchar(50) not null,
score int check(score>=0 or score<=100) not null
)

添加数据
insert into Info values('张三','男','12345678910')
insert into Info values('张三',default,'12345678911')
insert into Info values('张三','男','12345678912')
insert into Score values(10000,'数学',100)
select * from Info
select * from Score

posted on 2021-11-10 16:12  倾心于你  阅读(66)  评论(0)    收藏  举报