3.通过SQL语句管理数据表
1.创建数据表
创建表包括表名、字段、字段约束、表约束几个部分
--()内部的内容中每一个,分隔开来的部分相当于一个单独的命令 create table Scores ( StudentID int not null,--非空字段的定义是在类型定义后增加了"NOT NULL" ScoreTime datetime not null, Score decimal default 0,--默认值的定义在类型定义后增加"DEFAULT 默认值表达式" primary key (StudentID,ScoreTime),--主键,非空字段 foreign key (StudentID) references Students(Id)--外键,Students.Id必须被设置为主键才能关联 )
2.修改数据表
添加字段:
alter table Scores add flag bit
删除字段:
alter table Scores drop column b; --drop单列这么写可以
alter table Scores drop (b,c,d,e); --drop多列时这样写
3.删除数据表
drop table Scores