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

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

sql server数据建表的更多相关文章

  1. SQL SERVER 生成建表脚本

    /****** Object: StoredProcedure [dbo].[GET_TableScript_MSSQL] Script Date: 06/15/2012 11:59:00 ***** ...

  2. (转)SQL SERVER 生成建表脚本

    https://www.cnblogs.com/champaign/p/3492510.html /****** Object: StoredProcedure [dbo].[GET_TableScr ...

  3. 在SQL SERVER中获取表中的第二条数据

    在SQL SERVER中获取表中的第二条数据, 思路:先根据时间逆排序取出前2条数据作为一个临时表,再按顺时排序在临时表中取出第一条数据 sql语句如下: select top 1 * from(se ...

  4. 快速查看SQL Server 中各表的数据量以及占用空间大小

    快速查看SQL Server 中各表的数据量以及占用空间大小. CREATE TABLE #T (NAME nvarchar(100),ROWS char(20),reserved varchar(1 ...

  5. [SQL]SQL Server数据表的基础知识与增查删改

    SQL Server数据表的基础知识与增查删改 由张晨辉(学生) 于19天 前发表 | 阅读94次 一.常用数据类型 .整型:bigint.int.smallint.tinyint .小数:decim ...

  6. 使用Spark加载数据到SQL Server列存储表

    原文地址https://devblogs.microsoft.com/azure-sql/partitioning-on-spark-fast-loading-clustered-columnstor ...

  7. SQL Server数据表设计编辑后无法保存处理办法

    关于使用 SQL Server 企业管理器,表[设计]界面,修改数据表字段或类型无法保存的问题处理过程: 使用SQL Server数据库的你是否遇到过每次数据库编辑工具内点击设计修改表字段或类型要保存 ...

  8. SQL SERVER数据库的表中修改字段的数据类型后,不能保存

      在数据库里面建了一个表,可是由于对SQL SERVER的建表功能不熟悉,不知道把主键设成什么是好,就先设置了个TEXT类型,可是后来朋友们告诉我说,TEXT类型容易让数据文件变得很大,还 是改成一 ...

  9. MS SQL SERVER搜索某个表的主键所在的列名

    原文:MS SQL SERVER搜索某个表的主键所在的列名 SELECT SYSCOLUMNS.name  FROM SYSCOLUMNS,SYSOBJECTS,SYSINDEXES,SYSINDEX ...

随机推荐

  1. android 通过TimePickerDialog修改时间

    初学android,写了个修改时间的小程序,实现如下: 点击change按钮,弹出时间对话框: 然后点击Done,设置显示时间: 实现方式有两种, 一种是使用showDialog方法,不过此种方法已过 ...

  2. HDU 4444 Walk (离散化建图+BFS+记忆化搜索) 绝对经典

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4444 题意:给你一些n个矩形,给你一个起点,一个终点,要你求从起点到终点最少需要转多少个弯 题解:因为 ...

  3. java.lang.NoClassDefFoundError 异常

    在项目实施过程中,当访问某一个功能时,出现异常为  java.lang.NoClassDefFoundError  com/xxx/yyy/Zzzz > ,检查发现这个类实际已经存在于应用服务器 ...

  4. linux 服务器更主板后无法识别网卡处理过程

    linux 服务器更主板后无法识别网卡处理过程   服务器故障报修,主板坏,更换主板后无法识别网卡,ifconfig 查看只显示:lo loopback 127.0.0.1. 系统加载网卡驱动后会去读 ...

  5. Hacker(16)----防范端口扫描与嗅探

    端口扫描与嗅探都是黑客常用的招数,其目的是定位目标计算机和窃取隐私信息.为确保自己计算机的安全,用户需要掌握防范嗅探与端口扫描的常见措施,保障个人隐私信息安全. 一.掌握防范端口扫描的常用措施 防范端 ...

  6. java基础之反射

    反射的定义,反射的特性,反射的应用

  7. NFinal学习笔记(一)

    NFinal框架,最快的netWeb框架,其有三大特色,NFinalServer,NFinalBuild,NFinal代码生成器(生成web层) 首先学习了NFinalServer. NFinalSe ...

  8. (转)[老老实实学WCF] 第二篇 配置WCF

    在上一篇中,我们在一个控制台应用程序中编写了一个简单的WCF服务并承载了它.先回顾一下服务端的代码: using System; using System.Collections.Generic; u ...

  9. 《第一行代码》学习笔记17-碎片Fragment(2)

    1.碎片的状态和回调: (1)运行状态:碎片可见+所关联的活动处于运行状态. (2)暂停状态:当活动进入暂停状态(由于另一个未占满屏幕的活动被添加到栈顶),与其相关联的可见碎片会进入暂停状态. (3) ...

  10. 【mac osx安装opencv,python总结】

    在macosx下安装opencv,最大的困难在于协调python版本.由于在opencv官网上,强烈建议安装完整版的python(不建议使用mac 内置的python),所以会碰到这个多个python ...