zoukankan      html  css  js  c++  java
  • 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

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

  • 相关阅读:
    Markdown语法
    IDEA常用快捷键及基本操作
    这一份MySQL书单,可以帮你搞定90%以上的面试题!
    你真的以为计算机网络不重要吗,这份书单帮你搞定相关面试题!
    学好程序员必知必会的数据结构,这一份书单你值得拥有!
    送你一份Redis书单,以后使用缓存的问题不用再问我啦!
    这本最适合夯实基础的经典 Java 书籍,可能80% 的 Java 程序员没有认真看过!
    荐书在精不在多,推荐一份夯实Java基础的必备书单!
    拿万元月薪必备的书单,学JAVA的程序员必看的5本书!
    8岁上海小学生B站教编程惊动苹果,库克亲送生日祝福
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/3380655.html
Copyright © 2011-2022 走看看