ºÃÎĵµ - רҵÎÄÊéд×÷·¶ÎÄ·þÎñ×ÊÁÏ·ÖÏíÍøÕ¾

MySQLÊý¾Ý¿â»ù´¡ÓëʵÀý½Ì³ÌÁ·Ï°Ìâ²Î¿¼´ð°¸

ÓÉ ÌìÏ ·ÖÏí ʱ¼ä£º ¼ÓÈëÊÕ²Ø ÎÒҪͶ¸å µãÔÞ

´ð£ºÇë²Î¿´2.4.1Õ½ÚÄÚÈÝ¡£

15£®´´½¨studentÊý¾Ý¿â£¬²¢ÔÚ¸ÃÊý¾Ý¿âÖд´½¨student±í£¬ÓÃÓÚ±£´æÄúµÄ¸öÈËÐÅÏ¢£¨ÈçÐÕÃû¡¢ÐÔ±ð¡¢Éí·ÝÖ¤ºÅ¡¢³öÉúÈÕÆڵȣ©£¬²¢Íê³ÉÏÂÁвÙ×÷»òÎÊÌâ¡£

1£©ÉÏÊöµÄstudent±íÓÐûÓгöÏÖÊý¾ÝÈßÓàÏÖÏ󣿣¨Ìáʾ£º³öÉúÈÕÆÚ¿ÉÒÔÓÉÉí·ÝÖ¤ºÅÍÆËãµÃ³ö£©

´ð£º³öÉúÈÕÆÚ¿ÉÓÉÉí·ÝÖ¤ºÅ¼ÆËãµÃ³ö£¬ËùÒÔÉÏÊöµÄstudent±í´æÔÚÊý¾ÝÈßÓàÏÖÏó¡£ 2£©studentÊý¾Ý¿âĿ¼´æ·ÅÔÚÊý¾Ý¿â¸ùĿ¼ÖУ¬Ä¬ÈÏÇé¿öÏ£¬¸ùĿ¼ÊÇʲô£¿ ´ð£ºÊ¹ÓÃÃüÁî¡°show variables like 'datadir';¡±¿ÉÒԲ鿴²ÎÊýdatadirµÄÖµ¡£Ä¬ÈÏ°²×°MySQLºó£¬Êý¾Ý¿â¸ùĿ¼datadirµÄֵΪ¡°C:/Documents and Settings/All Users/Application Data/MySQL/MySQL Server 5.6/Data/¡±¡£

3£©ÈçºÎ²é¿´studentÊý¾Ý¿âµÄ½á¹¹¡£ ´ð£ºÇë²Î¿´2.3.3Õ½ÚÄÚÈÝ¡£

4£©ÈçºÎ²é¿´student±íµÄ½á¹¹£¬²¢²é¿´¸Ã±íµÄĬÈÏ×Ö·û¼¯¡¢×Ö·ûÐò¡¢´æ´¢ÒýÇæµÈÐÅÏ¢¡£ ´ð£ºÇë²Î¿´2.4.4Õ½ÚÄÚÈÝ¡£

5£©studentÊý¾Ý¿âĿ¼Öдæ·ÅÁËÄÄЩÎļþ£¿Êý¾Ý¿â¸ùĿ¼Öдæ·ÅÁËÄÄЩÎļþ£¿ ´ð£ºÇë²Î¿´2.4.1Õ½ÚÄÚÈÝ¡£

studentÊý¾Ý¿âĿ¼Öдæ·ÅÁËÈçÏÂÎļþ£º

(1) Êý¾Ý¿âÎļþ£¨Èçdb.opt£©

(2) ±íÃû¡¢ºó׺ÃûΪfrmµÄ±í½á¹¹¶¨ÒåÎļþ

(3) Èç¹ûstudentÊý¾Ý¿âÖдæÔÚInnoDB´æ´¢ÒýÇæµÄ¶ÀÏí±í¿Õ¼äµÄ±í£¬ÔòstudentÊý¾Ý¿âĿ¼Öл¹»á´æ·ÅÒ»¸öÃûΪ¡°±íÃû.ibd¡±µÄÊý¾ÝÎļþ¡£ (4) Èç¹ûstudentÊý¾Ý¿âÖдæÔÚMyISAM´æ´¢ÒýÇæµÄ±í£¬ÔòstudentÊý¾Ý¿âĿ¼Öлá´æÔÚÒ»¸öÎļþÃûΪ±íÃû¡¢ºó׺ÃûΪMYD£¨¼´MYDataµÄ¼òд£©µÄÊý¾ÝÎļþÒÔ¼°ÎļþÃûΪ±íÃû¡¢ºó׺ÃûΪMYI£¨¼´MYIndexµÄ¼òд£©µÄË÷ÒýÎļþ¡£ Êý¾Ý¿â¸ùĿ¼Öдæ·ÅÈçÏÂÎļþÒÔ¼°Ä¿Â¼£¨ÈçÏÂͼËùʾ£©£º

Êý¾Ý¿âĿ¼£¨ÀýÈçtestÊý¾Ý¿âĿ¼¡¢studentÊý¾Ý¿âĿ¼£© ib_logfile0¼°ib_logfile1ÊÇÖØ×öÈÕÖ¾Îļþ InnoDB¹²Ïí±í¿Õ¼äÎļþibdata1Îļþ

mysql-bin.000001µÈһϵÁжþ½øÖÆÈÕÖ¾Îļþ£¨¸Ã֪ʶµã³¬³ö±¾Õ·¶Î§£© mysql-bin.index¶þ½øÖÆÈÕÖ¾Ë÷ÒýÎļþ£¨¸Ã֪ʶµã³¬³ö±¾Õ·¶Î§£© mysqld.exe½ø³ÌIDºÅPIDÎļþ

auto.cnfÎļþ£ºserver_uuid£º·þÎñÆ÷Éí·ÝID¡£ÔÚµÚÒ»´ÎÆô¶¯MySQLʱ£¬»á×Ô¶¯Éú³ÉÒ»¸öserver_uuid²¢Ð´Èëµ½Êý¾Ý¿â¸ùĿ¼ÏÂauto.cnfÎļþÀ¹Ù·½²»½¨ÒéÐ޸ġ£

6£©½«¸öÈËÐÅÏ¢²åÈëµ½student±íÖУ¬²¢²éѯstudent±íµÄËùÓмǼ¡£

create database student; use student; create table student( name char(10) not null, sex char(3) not null, ID char(18) primary key ); insert into student values('ÕÅÈý','ÄÐ','410******001'); select * from student; 7£©ÔÚÉÏÒ»²½ÖèµÄ²éѯ½á¹ûÖÐÊÇ·ñ³öÏÖÁËÂÒÂ룿Èç¹û³öÏÖÁËÂÒÂ룬ÈçºÎ±ÜÃâÂÒÂëÎÊÌâµÄ·¢Éú£¿Èç¹ûûÓгöÏÖÂÒÂ룬¾­¹ýÄÄЩÉèÖÿÉÒÔ²úÉúÂÒÂ룿

Èç¹û³öÏÖÁËÂÒÂ룬ÖØÐÂɾ³ýÊý¾Ý¿â£¬ÖØÐÂÉèÖÃ×Ö·û¼¯£¬ÔÙ´´½¨Êý¾Ý¿âºÍÊý¾Ý¿â±í£¨ÒªÇóÔÚͬһ¸öMySQL»á»°ÖÐÒÀ´ÎÖ´ÐÐÏÂÁдúÂ룩£º drop database if exists student; set character_set_client = gbk; set character_set_connection = gbk; set character_set_database = gbk; set character_set_results = gbk; set character_set_server = gbk; create database student; use student; create table student( name char(10) not null, sex char(3) not null, ID char(18) primary key ); insert into student values('ÕÅÈý','ÄÐ','410******001'); select * from student; Èç¹ûûÓгöÏÖÂÒÂ룬¾­¹ýÄÄЩÉèÖÿÉÒÔ²úÉúÂÒÂ룺 set names latin1; select * from student;

8£©ÄúµÄ¸öÈËÐÅÏ¢´æ·Åµ½ÁËÄĸöÎļþÖУ¿

ÇéÐÎÒ»£ºÈç¹ûstudent±íÊÇMyISAM´æ´¢ÒýÇæµÄ±í£¬ÔòÔòÕÅÈýµÄÊý¾Ý´æ·ÅÔÚÒ»¸öÎļþÃûΪstudnet¡¢ºó׺ÃûΪMYD£¨¼´MYDataµÄ¼òд£©µÄÊý¾ÝÎļþ¡£

ÇéÐζþ£ºÈç¹ûstudent±íÊÇInnoDB´æ´¢ÒýÇæµÄ¹²Ïí±í¿Õ¼äµÄ±í£¬ÔòÕÅÈýµÄÊý¾Ý´æ·ÅÔÚInnoDB¹²Ïí±í¿Õ¼äÎļþibdata1Êý¾ÝÎļþ¡£

ÇéÐÎÈý£ºÈç¹ûstudent±íÊÇInnoDB´æ´¢ÒýÇæµÄ¶ÀÏí±í¿Õ¼äµÄ±í£¬ÔòÕÅÈýµÄÊý¾Ý´æ·ÅÔÚ¡°student.ibd¡±µÄÊý¾ÝÎļþ¡£

9£©ÈçºÎÐÞ¸Ästudent±íµÄ´æ´¢ÒýÇ棿ÐÞ¸Ästudent±íµÄ´æ´¢ÒýÇæºó£¬ÄúµÄ¸öÈËÐÅÏ¢´æ·Åµ½ÁËÄĸöÎļþÖУ¿

´ð°¸£º²Î¿¼ÉÏÒ»Ìâ¡£

10£©É¾³ýstudent±íÒÔ¼°studentÊý¾Ý¿â¡£ use student; drop table student; drop database student;

16£®ÄúËùÊìÖªµÄϵͳ±äÁ¿ÓÐÄÄЩ£¿ÈçºÎÉèÖÃϵͳ±äÁ¿µÄÖµ£¿ ´ð£ºÇë²Î¿´2.5.2Õ½ÚÄÚÈÝ¡£Çë²Î¿´2.5.3Õ½ÚÄÚÈÝ¡£

17£®ÈçºÎ½øÐÐÊý¾Ý¿â±¸·ÝºÍ»Ö¸´£¿±¸·ÝÆڼ䣬ÓÐÄÄЩעÒâÊÂÏ ´ð£ºÇë²Î¿´2.6Õ½ÚÄÚÈÝ¡£

µÚÈýÕ´ð°¸

1£®MySQLÊý¾Ý¿âÀàÐÍÓÐÄÄЩ£¿ÈçºÎÑ¡ÔñºÏÊʵÄÊý¾ÝÀàÐÍ£¿ ´ð£ºÇë²Î¿´3.1Õ½ÚÄÚÈÝ¡£Çë²Î¿´3.1.7Õ½ÚÄÚÈÝ¡£

2£®¼òµ¥×ܽáchar(n)Êý¾ÝÀàÐÍÓëvarchar(n)Êý¾ÝÀàÐÍÓÐÄÄЩÇø±ð¡£ ´ð£ºÇë²Î¿´3.1.3Õ½ÚÄÚÈÝ¡£

3£®datetimeÓëtimestampÊý¾ÝÀàÐÍÓÐʲôÇø±ð£¿ ´ð£ºÇë²Î¿´3.1.4Õ½ÚÄÚÈÝ¡£

4£®MySQLģʽÓëMySQL¸´ºÏÊý¾ÝÀàÐÍÓÐʲô¹Øϵ£¿ ´ð£ºÇë²Î¿´3.1.5Õ½ÚÄÚÈÝ¡£

5£®´´½¨SQL½Å±¾Îļþchoose.sql£¬ÊéдSQL´úÂ룬ÔËÐÐchoose.sql£¬´´½¨chooseÊý¾Ý¿âµÄ5ÕÅ±í¡£ set character_set_client = gbk; set character_set_connection = gbk; set character_set_database = gbk; set character_set_results = gbk; set character_set_server = gbk; create database choose; use choose; create table teacher( teacher_no char(10) primary key, teacher_name char(10) not null, #½ÌʦÐÕÃû²»ÔÊÐíΪ¿Õ teacher_contact char(20) not null #½ÌʦÁªÏµ·½Ê½Ãû²»ÔÊÐíΪ¿Õ )engine=InnoDB default charset=gbk; create table classes( class_no int auto_increment primary key, class_name char(20) not null unique, #°à¼¶Ãû²»ÔÊÐíΪ¿Õ¡¢ÇÒ²»ÔÊÐíÖظ´ department_name char(20) not null #ԺϵÃû²»ÔÊÐíΪ¿Õ )engine=InnoDB default charset=gbk; create table course( course_no int auto_increment primary key, course_name char(10) not null, #¿Î³ÌÃûÔÊÐíÖظ´ up_limit int default 60, #¿Î³ÌÉÏÏÞÉèÖÃĬÈÏֵΪ60 description text not null, #¿Î³ÌµÄÃèÊöÐÅϢΪÎı¾×Ö·û´®text£¬ÇÒ²»ÄÜΪ¿Õ status char(6) default 'δÉóºË', #¿Î³Ì״̬µÄĬÈÏֵΪ¡°Î´ÉóºË¡± teacher_no char(10) not null unique, #ΨһÐÔÔ¼ÊøʵÏÖ½ÌʦÓë¿Î³ÌÖ®¼ä1:1¹Øϵ constraint course_teacher_fk foreign key(teacher_no) references teacher(teacher_no) )engine=InnoDB default charset=gbk; create table student( student_no char(11) primary key, #ѧºÅ²»ÔÊÐíÖظ´ student_name char(10) not null, #ѧÉúÐÕÃû²»ÔÊÐíΪ¿Õ student_contact char(20) not null, #ѧÉúÁªÏµ·½Ê½²»ÔÊÐíΪ¿Õ class_no int , #ѧÉúµÄ°à¼¶ÔÊÐíΪ¿Õ constraint student_class_fk foreign key (class_no) references classes(class_no)

)engine=InnoDB default charset=gbk; create table choose( choose_no int auto_increment primary key, student_no char(11) not null, #ѧÉúѧºÅ²»ÔÊÐíΪ¿Õ course_no int not null, #¿Î³ÌºÅ²»ÔÊÐíΪ¿Õ score tinyint unsigned, choose_time datetime not null, #Ñ¡¿Îʱ¼ä¿ÉÓÉnow()º¯Êý×Ô¶¯Éú³É constraint choose_student_fk foreign key(student_no) references student(student_no), constraint choose_course_fk foreign key(course_no) references course(course_no) )engine=InnoDB default charset=gbk;

6£®·ÖÎöchooseÊý¾Ý¿âµÄ5ÕűíµÄ±í½á¹¹£¬Í¨¹ýÕâ5ÕÅ±í£¬¿ÉÒÔ½â¾ö¡°Ñ¡¿Îϵͳ¡±ÎÊÌâÓòÖеÄÄÄЩÎÊÌ⣿

´ð£ºÇë²Î¿´µÚÒ»Õ¿κóÏ°ÌâµÄ´ð°¸¡£

7£®ÄúÊÇÈçºÎÀí½âË÷ÒýµÄ£¿Ë÷ÒýÔ½¶àÔ½ºÃÂð£¿

´ð£ºÇë²Î¿´3.5Õ½ÚÄÚÈÝ¡£Çë²Î¿´3.5.1Õ½ÚÄÚÈÝ¡£

8£®Ë÷Òý¹Ø¼ü×ÖµÄÑ¡È¡Ô­ÔòÓÐÄÄЩ£¿ ´ð£ºÇë²Î¿´3.5.2Õ½ÚÄÚÈÝ¡£

9£®ÄúËùÊìÖªµÄË÷ÒýÖÖÀàÓÐÄÄЩ£¿Ê²Ã´ÊÇÈ«ÎÄË÷Òý£¿ ´ð£ºÇë²Î¿´3.5.4Õ½ÚÄÚÈÝ¡£ È«ÎÄË÷ÒýÓëÈ«ÎļìË÷

È«ÎÄË÷Òý£ºµ±²éѯÊý¾ÝÁ¿´óµÄ×Ö·û´®ÐÅϢʱ£¬Ê¹ÓÃÈ«ÎÄË÷Òý¿ÉÒÔ´ó·ùÌáÉý×Ö·û´®µÄ¼ìË÷ЧÂÊ¡£ÐèҪעÒâµÄÊÇ£¬È«ÎÄË÷ÒýÖ»ÄÜ´´½¨ÔÚchar¡¢varchar»òÕßtext×Ö·û´®ÀàÐ͵Ä×Ö¶ÎÉÏ£¬ÇÒÈ«ÎÄË÷Òý²»Ö§³Öǰ׺Ë÷Òý¡£

È«ÎļìË÷ÊÇÖ¸ÒÔÈ«²¿Îı¾ÐÅÏ¢×÷Ϊ¼ìË÷¶ÔÏóµÄÒ»ÖÖÐÅÏ¢¼ìË÷¼¼Êõ¡£ Õª×Ôhttp://wiki.mbalib.com/wiki/È«ÎļìË÷

±¾Êé5.10Õ½ÚÖУ¬Ò²¸ø³öÁËÈ«ÎļìË÷µÄ¶¨Ò壺¼òµ¥µØ˵£¬MySQLÖеÄÈ«ÎļìË÷ʹÓÃÌض¨µÄ·Ö´Ê¼¼Êõ£¬ÀûÓòéѯ¹Ø¼ü×ֺͲéѯ×Ö¶ÎÄÚÈÝÖ®¼äµÄÏà¹Ø¶È½øÐмìË÷¡£Í¨¹ýÈ«ÎÄË÷Òý¿ÉÒÔÌá¸ßÎı¾Æ¥ÅäµÄËٶȡ£

10£®Ë÷ÒýÓëÔ¼ÊøÓÐʲô¹Øϵ£¿ ´ð£ºÇë²Î¿´3.5.3Õ½ÚÄÚÈÝ¡£

MySQLÊý¾Ý¿â»ù´¡ÓëʵÀý½Ì³ÌÁ·Ï°Ìâ²Î¿¼´ð°¸

´ð£ºÇë²Î¿´2.4.1Õ½ÚÄÚÈÝ¡£15£®´´½¨studentÊý¾Ý¿â£¬²¢ÔÚ¸ÃÊý¾Ý¿âÖд´½¨student±í£¬ÓÃÓÚ±£´æÄúµÄ¸öÈËÐÅÏ¢£¨ÈçÐÕÃû¡¢ÐÔ±ð¡¢Éí·ÝÖ¤ºÅ¡¢³öÉúÈÕÆڵȣ©£¬²¢Íê³ÉÏÂÁвÙ×÷»òÎÊÌâ¡£1£©ÉÏÊöµÄstudent±íÓÐûÓгöÏÖÊý¾ÝÈßÓàÏÖÏ󣿣¨Ìáʾ£º³öÉúÈÕÆÚ¿ÉÒÔÓÉÉí·ÝÖ¤ºÅÍÆËãµÃ³ö£©´ð£º³öÉúÈÕÆÚ¿ÉÓÉÉí·ÝÖ¤ºÅ¼ÆËãµÃ³ö£¬ËùÒÔÉÏÊöµÄstudent±í
ÍƼö¶È£º
µã»÷ÏÂÔØÎĵµÎĵµÎªdoc¸ñʽ
8cezz67lc55gf8x599ez10e609m8f001b9f
ÁìÈ¡¸£Àû

΢ÐÅɨÂëÁìÈ¡¸£Àû

΢ÐÅɨÂë·ÖÏí