use master
go
if exists (select * from sys.databases where name=‘Demo‘)
drop database Demo
create database Demo
go
use Demo
go
create table Dept
(
ID int identity(1,1) primary key,
DeptID nvarchar(10),
DeptName nvarchar(10)
)
go
create table UserInfo
(
ID int identity(1,1) primary key,
UserName nvarchar(10),
Salary Decimal(10,2),
Gender bit,
DeptID int foreign key references Dept(ID)
)
go
insert into Dept values
(‘1001‘,‘人事部‘),
(‘1002‘,‘财务部‘),
(‘1003‘,‘开发部‘)
insert into UserInfo values
(‘小王‘,3000,0,1),
(‘小李‘,2000,0,2),
(‘小菜‘,5000,1,3),
(‘小芳‘,3500,1,1)
go