今天在论坛上看到一个乱码问题,突然想起mysql(这里使用6.x,还要指定引擎类型)在建数据库,表时要指定字符集类型。
create database dultscore DEFAULT CHARACTER SET gbk ;
use dultscore;
create table scoreLogin(
sl_num char(6) NOT NULL primary key,
sl_name char(10)NOT NULL,
sl_pass char(16)NOT NULL,
sl_permession int NOT NULL
)Engine=MyISAM
DEFAULT CHARACTER SET gbk ;
insert into scoreLogin values('admin','admin','admin',3);
create table collage
(
coll_id int not null auto_increment primary key,
coll_name varchar(30)NOT NULL
)Engine=MyISAM
DEFAULT CHARACTER SET gbk;
create table professional
(
pro_id int not null auto_increment primary key,
pro_name varchar(30) NOT NULL,
coll_name varchar(30) NOT NULL
)Engine=MyISAM
DEFAULT CHARACTER SET gbk;
create table semester
(
semester char(26) NOT NULL primary key
)Engine=MyISAM
DEFAULT CHARACTER SET gbk;
create table schoolyear
(
schoolyear char(4) NOT NULL primary key
)Engine=MyISAM
DEFAULT CHARACTER SET gbk;
create table course
(
courseId char(6) NOT NULL primary key,
courseName char(4)NOT NULL,
courseRight int NOT NULL,
courseType int NOT NULL
)Engine=MyISAM
DEFAULT CHARACTER SET gbk;
create table proSemester
(
proSemId int not null auto_increment primary key,
proSemCollName varchar(30)NOT NULL,
proSemProName varchar(30)NOT NULL,
proSemSemester char(26)NOT NULL,
proSemSchoolyear char(4)NOT NULL
)Engine=MyISAM
DEFAULT CHARACTER SET gbk;
create table semesterTeacher
(
semTea_Id int not null auto_increment primary key,
semTea_ProSem_Id int NOT NULL,
semTea_TeacherNum char(6) NOT NULL,
semTea_Class char(4) NOT NULL
)Engine=MyISAM
DEFAULT CHARACTER SET gbk;
create table semesterCourse
(
semCour_ProSem_Id int NOT NULL,
semCour_CourseId char(6) NOT NULL,
primary key(semCour_ProSem_Id ,semCour_CourseId)
)Engine=MyISAM
DEFAULT CHARACTER SET gbk;
create table semesterStudent
(
semStu_proSem_Id int NOT NULL,
semStu_stuNum char(9) NOT NULL,
semStu_stuName varchar(8) NOT NULL,
semStu_stuClass char(4)NOT NULL,
semStu_stuSta int default 1 NOT NULL,
primary key(semStu_proSem_Id ,semStu_stuNum)
)Engine=MyISAM
DEFAULT CHARACTER SET gbk;
create table semesterResults
(
semRes_SemTea_Id int NOT NULL,
semRes_proSem_Id int NOT NULL,
semRes_StuClass char(4)NOT NULL,
semRes_StuNum char(9) NOT NULL,
semRes_CourseId char(6)NOT NULL,
semRes_semResScore char(1)NOT NULL,
primary key(semRes_SemTea_Id,semRes_StuNum,semRes_CourseId)
)Engine=MyISAM
DEFAULT CHARACTER SET gbk;