尊龙凯时人生就是搏

mysqlÖÐcheckÔ¼ÊøÔõôÓÃ

mysql ÖÐµÄ check Ô¼ÊøÓÃÓÚÏÞÖƱíÖÐÊý¾ÝÖµµÄ¹æÄ££¬Ê¹ÓÃÓï·¨£ºalter table table_name add constraint constraint_name check (column_name expression)¡£Óŵã°üÀ¨Êý¾ÝÍêÕûÐÔ¡¢ÐÔÄܺͿÉά»¤ÐÔ£¬×¢ÖØÊÂÏîÊÇÖ»ÊÊÓÃÓÚµ¥¸öÁУ¬±í´ïʽ±ØÐè·µ»Ø²¼¶ûÖµ£¬Ô¼ÊøÃû³Æ±ØÐèΨһ¡£

MySQL ÖÐµÄ CHECK Ô¼Êø

ÔÚ MySQL ÖУ¬CHECK Ô¼ÊøÓÃÓÚÏÞÖƱíÖеÄÊý¾ÝÖµ¡£Ëüͨ¹ýÖ¸¶¨Ò»¸ö²¼¶û±í´ïʽÀ´½ç˵ÔÊÐí´æ´¢ÔÚ±íÖеÄÖµ¹æÄ£¡£

ÔõÑùʹÓà CHECK Ô¼Êø

Òª½¨Éè CHECK Ô¼Êø£¬ÇëʹÓÃÒÔÏÂÓï·¨£º

ALTER TABLE table_name ADD CONSTRAINT constraint_name CHECK (column_name expression);

µÇ¼ºó¸´ÖÆ

ÆäÖУº

table_name ÊÇÒªÌí¼ÓÔ¼ÊøµÄ±íÃû¡£

constraint_name ÊÇÔ¼ÊøµÄΨһÃû³Æ¡£

column_name ÊÇÒªÓ¦ÓÃÔ¼ÊøµÄÁÐÃû¡£

expression ÊÇÒ»¸ö²¼¶û±í´ïʽ£¬Ëü½ç˵ÁËÔÊÐí´æ´¢ÔÚ¸ÃÁÐÖеÄÖµ¡£

ÔõÑùʹÓà CHECK Ô¼ÊøʾÀý

ÀýÈ磬Ҫ½¨ÉèÒ»¸ö½öÔÊÐíÕýÊýµÄ±íÃûΪ employees µÄ±íÖÐ salary ÁУ¬¿ÉÒÔʹÓÃÒÔÏÂÔ¼Êø£º

ALTER TABLE employees ADD CONSTRAINT positive_salary CHECK (salary > 0);

µÇ¼ºó¸´ÖÆ

CHECK Ô¼ÊøµÄÓŵã

ʹÓà CHECK Ô¼ÊøÓÐÒÔÏÂÓŵ㣺

Êý¾ÝÍêÕûÐÔ£ºËüÈ·±£Ö»ÓÐÇкÏÔ¼ÊøÌõ¼þµÄÖµ²Å»ª²åÈëµ½±íÖС£

ÐÔÄÜ£ºËü¿ÉÒÔÔÚ²åÈëʱ¿ìËÙÑéÖ¤Êý¾Ý£¬´Ó¶øïÔÌ­ÎÞЧÊý¾ÝµÄ´æ´¢¡£

¿Éά»¤ÐÔ£ºËüʹÁÐÔ¼Êø¸üÒ×ÓÚÃ÷È·ºÍÖÎÀí¡£

CHECK Ô¼ÊøµÄ×¢ÖØÊÂÏî

ÒÔÏÂÐèҪעÖØһЩÊÂÏ

CHECK Ô¼ÊøÖ»ÄÜÓ¦ÓÃÓÚµ¥¸öÁС£

±í´ïʽ±ØÐèʼÖÕ·µ»Ø TRUE »ò FALSE Öµ¡£

Ô¼ÊøÃû³Æ±ØÐèÔÚ±íÖÐΨһ¡£

ÒÔÉϾÍÊÇmysqlÖÐcheckÔ¼ÊøÔõôÓõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ