navicatÔõô¿´Íâ¼üÊÓͼ
ÔÚ navicat ÖÐÉó²éÍâ¼üÊÓͼÓÐÈýÖÖÒªÁ죺ֱ½Ó»á¼û£¨²éÕÒÒÔ¡°fk_¡±¿ªÍ·µÄÊÓͼ£©¡¢ÅÌÎÊÊÓͼ£¨´ÓÊÓͼ½ÚµãÓÒ¼üµ¥»÷¡°ÅÌÎÊÊý¾Ý¡±£©£¬»òÕö¿ª information_schema.key_column_usage ±í£¬²¢Ê¹ÓÃÊʵ±µÄɸѡÆ÷À´Ê¶±ðÍâ¼üÒýÓá£
ÔõÑùʹÓà Navicat Éó²éÍâ¼üÊÓͼ
Ö±½Ó»á¼û
ÅþÁ¬µ½Êý¾Ý¿â¡£
ÔÚ¹¤¾ßÊ÷ÖÐÕö¿ª¡°ÊÓͼ¡±½Úµã¡£
²éÕÒÒÔ¡°FK_¡±¿ªÍ·µÄÊÓͼ£¬ÕâЩÊÓͼÌåÏÖÍâ¼ü¹Øϵ¡£
ÅÌÎÊÊÓͼ
ÔÚ¹¤¾ßÊ÷ÖÐÓÒ¼üµ¥»÷¡°ÊÓͼ¡±½Úµã¡£
Ñ¡Ôñ¡°ÅÌÎÊÊý¾Ý¡±¡£
ÔÚ SQL ÅÌÎʱà¼Æ÷ÖУ¬ÊäÈëÒÔÏÂÅÌÎÊ£º
SELECT * FROM <view_name></view_name>
µÇ¼ºó¸´ÖÆ
ÆäÖÐ ÊÇÄúÒªÉó²éµÄÍâ¼üÊÓͼµÄÃû³Æ¡£
Õö¿ª INFORMATION_SCHEMA.KEY_COLUMN_USAGE ±í
ÔÚ¹¤¾ßÊ÷ÖÐÕö¿ª¡°ÏµÍ³±í¡±½Úµã¡£
ÕÒµ½²¢Õö¿ª INFORMATION_SCHEMA.KEY_COLUMN_USAGE ±í¡£
ʹÓÃÒÔÏÂɸѡÆ÷Éó²éÍâ¼üÒýÓãº
TABLE_NAME£ºÍâ¼üËùÔڵıí
CONSTRAINT_NAME£ºÍâ¼üÔ¼ÊøµÄÃû³Æ
REFERENCED_TABLE_NAME£ºÒýÓõıí
REFERENCED_COLUMN_NAME£ºÒýÓõÄÁÐ
ʾÀý
¼ÙÉèÎÒÃÇÓÐÒ»¸öÃûΪ Customers µÄ±í£¬ÆäÖаüÀ¨Ò»¸öÃûΪ customer_id µÄÍâ¼ü£¬ËüÒýÓà Orders ±íÖÐµÄ order_id ÁС£
ÒªÉó²é±ðµÄ¼üÊÓͼ£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏ°취£º
Ö±½Ó»á¼û£ºÔÚ¹¤¾ßÊ÷ÖУ¬Õö¿ª¡°ÊÓͼ¡±½Úµã£¬È»ºó²éÕÒÃûΪ FK_Customers_Orders µÄÊÓͼ¡£
ÅÌÎÊÊÓͼ£ºÓÒ¼üµ¥»÷ FK_Customers_Orders ÊÓͼ£¬È»ºóÑ¡Ôñ¡°ÅÌÎÊÊý¾Ý¡±¡£
Õö¿ª INFORMATION_SCHEMA.KEY_COLUMN_USAGE ±í£ºÔÚɸѡÆ÷ÖУ¬Ö¸¶¨ TABLE_NAME Ϊ Customers£¬CONSTRAINT_NAME Ϊ FK_Customers_Orders£¬REFERENCED_TABLE_NAME Ϊ Orders£¬REFERENCED_COLUMN_NAME Ϊ order_id¡£
ÒÔÉϾÍÊÇnavicatÔõô¿´Íâ¼üÊÓͼµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡