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
这里用到了创建数据表,删除数据表,字段类型等知识
sql server数据建表的更多相关文章
- SQL SERVER 生成建表脚本
/****** Object: StoredProcedure [dbo].[GET_TableScript_MSSQL] Script Date: 06/15/2012 11:59:00 ***** ...
- (转)SQL SERVER 生成建表脚本
https://www.cnblogs.com/champaign/p/3492510.html /****** Object: StoredProcedure [dbo].[GET_TableScr ...
- 在SQL SERVER中获取表中的第二条数据
在SQL SERVER中获取表中的第二条数据, 思路:先根据时间逆排序取出前2条数据作为一个临时表,再按顺时排序在临时表中取出第一条数据 sql语句如下: select top 1 * from(se ...
- 快速查看SQL Server 中各表的数据量以及占用空间大小
快速查看SQL Server 中各表的数据量以及占用空间大小. CREATE TABLE #T (NAME nvarchar(100),ROWS char(20),reserved varchar(1 ...
- [SQL]SQL Server数据表的基础知识与增查删改
SQL Server数据表的基础知识与增查删改 由张晨辉(学生) 于19天 前发表 | 阅读94次 一.常用数据类型 .整型:bigint.int.smallint.tinyint .小数:decim ...
- 使用Spark加载数据到SQL Server列存储表
原文地址https://devblogs.microsoft.com/azure-sql/partitioning-on-spark-fast-loading-clustered-columnstor ...
- SQL Server数据表设计编辑后无法保存处理办法
关于使用 SQL Server 企业管理器,表[设计]界面,修改数据表字段或类型无法保存的问题处理过程: 使用SQL Server数据库的你是否遇到过每次数据库编辑工具内点击设计修改表字段或类型要保存 ...
- SQL SERVER数据库的表中修改字段的数据类型后,不能保存
在数据库里面建了一个表,可是由于对SQL SERVER的建表功能不熟悉,不知道把主键设成什么是好,就先设置了个TEXT类型,可是后来朋友们告诉我说,TEXT类型容易让数据文件变得很大,还 是改成一 ...
- MS SQL SERVER搜索某个表的主键所在的列名
原文:MS SQL SERVER搜索某个表的主键所在的列名 SELECT SYSCOLUMNS.name FROM SYSCOLUMNS,SYSOBJECTS,SYSINDEXES,SYSINDEX ...
随机推荐
- BZOJ2084: [Poi2010]Antisymmetry
2084: [Poi2010]Antisymmetry Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 187 Solved: 125[Submit] ...
- Paint House II 解答
Question There are a row of n houses, each house can be painted with one of the k colors. The cost o ...
- (step5.1.6)hdu 1272(小希的迷宫——并查集)
题目大意:输入一系列的点,判断这些点组成的图符不符合小希的思路(无环.连通) 解题思路: 1)如果两个节点的根节点相同,那么在这两个节点之间添加1条边以后,这个图肯定有环路. 2)孤立节点:被使用过& ...
- c语言局部变量 静态局部变量 全局变量与静态全局变量
基本概念: 作用域:起作用的区域,也就是可以工作的范围. 代码块:所谓代码块,就是用{}括起来的一段代码. 数据段:数据段存的是数,像全局变量就是存在数据段的 代码段:存的是程序代码,一般是只读的. ...
- python3-day5(模块)
1.获取路径import os,sys #获取全部路径 print(os.path.abspath(__file__)) #获取目录 print(os.path.dirname(os.path.abs ...
- Java IO :文件
在java应用程序中,文件是一种常用的数据源或者存储数据的媒介.所以这一小节将会对Java中文件的使用做一个简短的概述.这里只提供一些必要的知识点. 通过Java IO读文件 如果你需要在不同端之间读 ...
- WebService-相关概念介绍
WebService学习总结(二)——WebService相关概念介绍 一.WebService是什么? 1. 基于Web的服务:服务器端整出一些资源让客户端应用访问(获取数据) 2. 一个跨语言.跨 ...
- java.lang.NoSuchFieldError: deferredExpression解决
java.lang.NoSuchFieldError: deferredExpression这个问题的出现是在的lib下面有多个版本的jstl.jar包,解决办法很简单,只留下一个版本的jstl ...
- [Regular Expressions] Find Repeated Patterns
Regular Expression Quantifiers allow us to identify a repeating sequence of characters of minimum an ...
- swift调用相机和相册
简单实现swift调用相机和相册的功能,分享代码与学习swift的童鞋共同进步 import UIKit class ViewController: UIViewController,UIImageP ...