navicat±íÓë±íÖ®¼äÔõôÓÃÊÓͼÅþÁ¬ÆðÀ´
ÔÚ navicat ÖÐͨ¹ýÊÓͼÅþÁ¬±í¿ÉʵÏÖ±ã½ÝµÄÊý¾Ý»á¼ûºÍÅÌÎÊ£º½¨ÉèÊÓͼ£¬Ê¹Óà sql Óï¾ä½«ËùÐè×ֶδӲî±ð±íÖÐÅþÁ¬ÔÚÒ»Æð¡£ÅþÁ¬ÊÓͼ£¬½«½¨ÉèºÃµÄÊÓͼÍϷŵ½ÅÌÎʱà¼Æ÷ÖС£Ö´ÐÐÅÌÎÊ£¬ÊäÈë sql ÅÌÎʲ¢Ö´Ðм´¿ÉÉó²éÅþÁ¬ºóµÄÊý¾Ý¡£
NavicatÖÐʹÓÃÊÓͼÅþÁ¬±í
ÔÚNavicatÊý¾ÝÖÎÀí¹¤¾ßÖУ¬¿ÉÒÔͨ¹ýÊÓͼ½«²î±ðµÄ±íÅþÁ¬ÆðÀ´£¬´Ó¶øÀû±ãµØ»á¼ûºÍÅÌÎÊÊý¾Ý¡£ÒÔÏÂÊÇÏêϸ°ì·¨£º
1. ½¨ÉèÊÓͼ
ÓÒ¼üµ¥»÷Êý¾Ý¿âÃû³Æ£¬Ñ¡Ôñ”н¨” > “ÊÓͼ”¡£
ÔÚ”ÊÓͼ±à¼Æ÷”ÖУ¬ÊäÈëÒÔÏÂSQLÓï¾ä£º
CREATE VIEW ÊÓͼÃû³Æ AS SELECT ×Ö¶Î1, ×Ö¶Î2, ... FROM ±íÃû1 LEFT JOIN ±íÃû2 ON ±íÃû1.×Ö¶Î1 = ±íÃû2.×Ö¶Î2 ...
µÇ¼ºó¸´ÖÆ
ÐÞ¸Ä×Ö¶Î1¡¢×Ö¶Î2µÈΪҪÅþÁ¬µÄ×ֶΣ¬Ð޸ıíÃû1¡¢±íÃû2µÈΪҪÅþÁ¬µÄ±í¡£
2. ÅþÁ¬ÊÓͼ
ÔÚÊý¾Ý¿âÊ÷ÖÐÕö¿ªÊý¾Ý¿â£¬ÕÒµ½½¨ÉèºÃµÄÊÓͼ¡£
½«ÊÓͼÍϷŵ½ÅÌÎʱà¼Æ÷ÖС£
ÊÓͼ½«×÷ΪÐÂÅÌÎÊÖеıíÅþÁ¬¡£
3. Ö´ÐÐÅÌÎÊ
ÊäÈëÒªÖ´ÐеÄSQLÅÌÎÊ¡£
ÀýÈ磺
SELECT * FROM ÊÓͼÃû³Æ
µÇ¼ºó¸´ÖÆ
4. Éó²éЧ¹û
Ö´ÐÐÅÌÎʺó£¬Navicat½«ÏÔʾÊÓͼÖаüÀ¨µÄËùÓÐÊý¾Ý¡£
ʾÀý
¼ÙÉèÓÐÒÔÏÂÁ½ÕÅ±í£º
Ô±¹¤±í£¨Employee£©£ºID¡¢ÐÕÃû¡¢²¿·Ö
²¿·Ö±í£¨Department£©£ºID¡¢²¿·ÖÃû³Æ
Òª½¨ÉèÒ»¸öÅþÁ¬ÕâÁ½¸ö±íµÄÊÓͼ£¬¿ÉÒÔͨ¹ýÒÔÏÂSQLÓï¾ä£º
CREATE VIEW EmployeeDepartment AS SELECT e.ID, e.Name, e.DepartmentID, d.DepartmentName FROM Employee e LEFT JOIN Department d ON e.DepartmentID = d.ID
µÇ¼ºó¸´ÖÆ
È»ºó£¬¿ÉÒÔÔÚÅÌÎʱà¼Æ÷ÖÐÍÏ·ÅEmployeeDepartmentÊÓͼ£¬²¢Ö´ÐÐÅÌÎÊÒÔÉó²éÅþÁ¬ºóµÄÊý¾Ý¡£
ÒÔÉϾÍÊÇnavicat±íÓë±íÖ®¼äÔõôÓÃÊÓͼÅþÁ¬ÆðÀ´µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡