sql server数据建表

use edudb
go
if exists(select * from sysobjects where name='department')
drop table department
create table department(
  id int identity(1,1) primary key,
  name varchar(20) not null,
  user_id int not null,
  user_name varchar(20) null,
  note text null,
  status int null
)
go

if exists(select * from sysobjects where name='departmember')
drop table departmember
create table departmember(
  id int identity(1,1) primary key,
  department_id int not null,
  user_id int not null,
  user_name varchar(20) null,
  role int null,
  status int null
)
go

if exists(select * from sysobjects where name='division')
drop table division
create table division(
  id int identity(1,1) primary key,
  name varchar(20) not null,
  user_id int not null,
  user_name varchar(20) null,
  note text null,
  status int null
)
go

if exists(select * from sysobjects where name='divisionmember')
drop table divisionmember
create table divisionmember(
  id int identity(1,1) primary key,
  division_id int not null,
  user_id int not null,
  user_name varchar(20) null,
  role int null,
  status int null
)
go

if exists(select * from sysobjects where name='class')
drop table class
create table class(
  id int identity(1,1) primary key,
  name varchar(20) not null,
  grade int not null,
  master_id int null,
  master_name varchar(20) null,
  master_tel char(20) null,
  status int null
)
go

if exists(select * from sysobjects where name='user')
drop table [user]
create table [user](
  id int identity(1,1) primary key,
  name varchar(20) not null,
  birth decimal(17,6) not null,
  avatar varchar(100) null,
  auth_id int null,
  nick varchar(50) not null,
  pwd varchar(50) not null,
  lastlogin decimal(17,6) not null,
  lastip char(20) not null,
  addtime decimal(17,6) not null,
  status int null
)
go

if exists(select * from sysobjects where name='auth')
drop table [auth]
create table [auth](
  id int identity(1,1) primary key,
  name varchar(20) not null,
  code varchar(100) null,
  status int null
)
go

if exists(select * from sysobjects where name='teacher')
drop table [teacher]
create table [teacher](
  id int identity(1,1) primary key,
  user_id int not null,
  realname char(20) not null,
  workno char(20) not null,
  avatar varchar(100) null,
  certype int not null,
  cerno varchar(50) not null,
  sex tinyint not null,
  birth decimal(17,6) not null,
  status int not null,
  nation char(20) not null,
  domicile char(20) not null,
  birthloca varchar(100) not null,
  speciality char(20) not null,
  degree char(20) not null,
  graduatetime decimal(17,6) not null,
  graduateschool varchar(100) not null,
  langtype tinyint not null,
  langlevel tinyint not null,
  worklevel tinyint not null,
  chineselevel tinyint not null,
  proftype tinyint not null,
  party char(20) not null,
  partytime decimal(17,6) not null,
  curhow varchar(50) not null,
  curway varchar(50) not null,
  curtime decimal(17,6) not null,
  worktime decimal(17,6) not null,
  enroltime decimal(17,6) not null,
  flag1 tinyint not null,
  flag2 tinyint not null,
  flag3 tinyint not null,
  flag4 tinyint not null,
  flag5 tinyint not null,
  teachtime decimal(17,6) not null,
  retiretime decimal(17,6) not null,
  level tinyint not null,
  positionlevel tinyint not null,
  managetype tinyint not null,
  position char(20) not null,
  type1 int not null,
  type2 int not null,
  appleid char(50) not null,
  address varchar(100) not null,
  tel varchar(50) not null,
  mobile varchar(50) not null,
  qq char(20) null,
  email varchar(50) not null,
  bank1 varchar(50) not null,
  bank1no varchar(50) not null,
  bank2 varchar(50) not null,
  bank2no varchar(50) not null,
  healthcard varchar(50) not null,
  division_id int not null,
  division_name varchar(50) not null,
  department_id int not null,
  department_name varchar(50) not null
)
go

if exists(select * from sysobjects where name='semester')
drop table [semester]
create table [semester](
  id int identity(1,1) primary key,
  startime decimal(17,6) not null,
  endtime decimal(17,6) not null,
  name varchar(20) null,
  year char(20) null,
  ord int null,
  status int null
)
go

if exists(select * from sysobjects where name='course')
drop table [course]
create table [course](
  id int identity(1,1) primary key,
  name varchar(20) not null,
  belong int not null,
  score tinyint not null,
  max char(20) null,
  min char(20) null,
  status int null
)
go

这里用到了创建数据表,删除数据表,字段类型等知识

上一篇:Hibernate关联关系映射之一对多双向映射


下一篇:大话设计模式C++达到-文章12章-外观模式