数据库(实验2 数据库表)

创建数据库


//创建数据库数据文件
create database testbase2
on
(name=testbase2_data,
 filename='D:\张小山数据库\lianxi2\testbase2_data.mdf',
 size=5mb,
 maxsize=50mb,
 filegrowth=20%)
 //创建数据库的日志文件
 log on 
 (name=testbase2_log,
  filename='D:\张小山数据库\lianxi2\testbase2_log.ldf',
  size=20mb,
  maxsize=500mb,
  filegrowth=10mb)

/1建教师表/

  create table Teacher
  (TNO char(2) not null,
   TN char(8) not null,
   SEX char(2),
   AGE tinyint,
   PROF char(10),
   SAL smallint,
   COMM smallint,
   DEPT char(10))

/2建学生表/

  create table Student
  (SNO char(2) not null,
   SN char(8) not null,
   SEX char(2),
   AGE tinyint,
   DEPT char(10))

/3建课程表/

  create table Course
  (CNO char(2) not null,
   CN char(10) not null,
   CT tinyint)

/4建选课表/

create table SC
  (SNO char(2) not null,
   CNO char(2) not null,
   CT tinyint)

/5建授课表/

  create table TC
  (TNO char(2) not null,
   CNO char(2) not null,
   Evalution char(20))

数据库表的删除


  /*删除Teacher表*/
  drop table Teacher
  /*删除Student表*/
  drop table Student
  /*删除Course表*/
  drop table Course
  /*删除SC表*/
  drop table SC
  /*删除TC表*/
  drop table TC

数据库表的增加、修改

  /*增加Student的NATIVE列*/
  ALTER table Student
   ADD NATIVE char(40) null
   
  /*修改数据库表Student中的列NATIVE*/
  alter table Student
	alter column NATIVE char(16) null
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值