1、数据定义、数据操纵、数据查询语句。
(1)创建数据库,置为当前数据库;
create database test
use test
(2)创建表(参看表结构),包括主码、外码及其它完整性约束;
Student表结构
列名说明数据类型约束
Sno 学号定长字符串,长度为7 主码
Sname 姓名定长字符串,长度为10 非空
Ssex 性别定长字符串,长度为2 取’男’或’女’
Sage 年龄微整形(tinyint)取值15~45
Sdept 所在系不定长字符串,长度为20 默认为’计算机系’Spec 专业定长字符串,长度为10
create table student(
sno char(7) primary key,
sname char(10) not null ,
ssex char(2) check(ssex='男'or ssex='女'),
sage tinyint check(sage>=15 AND sage<=45) ,
sdept varchar(20) default'计算计系',
spec char(10)
)
Course表结构
列名说明数据类型约束
Cno 课程号定长字符串,长度为10 主码
Cname 课程名不定长字符串,长度为20 非空
Ccredit 学分小整数(smallint)取值大于0
Semster 学期小整数(smallint)取值大于0
Periods 学时数小整数(smallint)取值大于0
Property 课程性质定长字符串,长度为4
create table course(