建表

来源:互联网 发布:淘宝众筹 淘宝怎么不管 编辑:程序博客网 时间:2024/05/01 18:08

代码

--建表use StudentManager--指定if exists (select *from sysobjects where name='tbl+student')--判断drop table tbl_student--有就删除之后创建,没有就创建create table tbl_student(id int identity (1,1)primary key,--自增变量从1开始增加每次加1,设为主键stu_number char(10)not null,--学号不许为空stu_name varchar(20)not null,--注意特例stu_age int,birthday datetime,class_id int references tbl_class(class_id)--第一个是表中的名字,第二个是class表中的class_id--创建外键)use StudentManager--指定if exists (select *from sysobjects where name='tbl_class')--判断drop table tbl_class--有就删除之后创建,没有就创建create table tbl_class(class_id int identity (1,1)primary key,--自增变量从1开始增加每次加1,设为主键stu_number char(10)not null,--学号不许为空class_name varchar(20)not null,create_time datetime)

运行图片



小结:--文件恢复上次写的查询语句


0 0
原创粉丝点击