1.数据库和表的创建

数据库的创建

create database YGGL2
on(
name="YGGL2",
filename="C:Program FilesMicrosoft SQL ServerMSSQL11.WANGXUELIANGMSSQLDATAYGGL2.mdf",
size=10mb,
maxsize=50mb,
filegrowth=5%
)
log on(
name="YGGL_log2",
filename="C:Program FilesMicrosoft SQL ServerMSSQL11.WANGXUELIANGMSSQLDATAYGGL_log2.ldf",
size=2mb,
maxsize=5mb,
filegrowth=1mb
)

表的创建

create table Employees
(
EmpID char(6) not null primary key,
EmpName char(10) not null,
EmpEdu char(4) not null,
EmpBir date not null,
EmpSex bit not null default 0,
WorkYear tinyint,
Addres varchar(40),
PhoneNum char(12),
DepID char(3) not null
)

--创建部门表
create table  Departments
(
DepID char(3) not null primary key,
DepName char(20) not null,
Note varchar(100),
)

--创建工资表
create table  Salary
(
EmpID char(6) not null primary key,
InCome float not null,
OntCome float not null
)

临时表的创建

--创建临时表
create table #temp
(
EmpID int not null primary key,
EmpAdd varchar(20)
)


原文地址:https://www.cnblogs.com/wangxueliang/p/9346515.html