最近在学习SQL Server,所以想把一些学习的知识记录下来。 1.建立表结构 学生表 CREATE TABLE [ dbo ] . [ t_student ] ( [ student_id ] [ nchar ] ( 8 ) COLLATE Chinese_PRC_CI_AS NOT NULL , -- 学号 [ classes_id ] [ nchar ] ( 8 ) COLLATE Chinese_PRC_CI_AS NULL , -- 班级 [ student_name ] [ varchar ] ( 12 ) COLLATE Chinese_PRC_CI_AS NOT NULL , -- 姓名 [ sex ] [ char ] ( 2 ) COLLATE Chinese_PRC_CI_AS NULL , -- 性别 [ birth_date ] [ datetime ] NULL , -- 出生年月 [ credit_hour ] [ int ] NULL , -- 学分 [ address ] [ varchar ] ( 100 ) COLLATE Chinese_PRC_CI_AS NULL , -- 地址 CONSTRAINT [ PK_t_student ] PRIMARY KEY CLUSTERED ( [ student_id ] ASC ) WITH (IGNORE_DUP_KEY = OFF ) ON [ PRIMARY ] ) ON [ PRIMARY ] 课程表 CREATE TABLE [ dbo ] . [ t_course ] ( [ course_id ] [ nchar ] ( 4 ) COLLATE Chinese_PRC_CI_AS NOT