×ðÁú¿­Ê±¹ÙÍøµÇ¼

mysqlÖÐ@µÄÓ÷¨

ÔÚ mysql ÖУ¬@ ·ûºÅµÄÓ÷¨Ö÷ÒªÓУº1. ÉùÃ÷ºÍ»ñÈ¡Óû§±äÁ¿£»2. »ñȡϵͳ±äÁ¿µÄÖµ£»3. ´æ´¢Àú³Ì²ÎÊýÉùÃ÷ºÍת´ï£»4. ¼ì²éÅÌÎÊ»º´æÖÀÖУ»5. ½¨ÉèÔÝʱ±í ¡£

MySQL ÖÐµÄ @ ·ûºÅÓ÷¨

ÔÚ MySQL ÖУ¬@ ·ûºÅ¾ßÓÐÒÔϼ¸ÖÖÓ÷¨£º

1. Óû§±äÁ¿

@ ·ûºÅ¿ÉÓÃÓÚÉùÃ÷ºÍ»ñÈ¡Óû§±äÁ¿ ¡£Ó﷨Ϊ£º

SET @variable_name = value;

µÇ¼ºó¸´ÖÆ

ÀýÈ磺

SET @total_sales = (SELECT SUM(sales) FROM orders);

µÇ¼ºó¸´ÖÆ

2. ϵͳ±äÁ¿

@ ·ûºÅ»¹¿ÉÓÃÓÚ»ñȡϵͳ±äÁ¿µÄÖµ ¡£Ó﷨Ϊ£º

SELECT @@system_variable_name;

µÇ¼ºó¸´ÖÆ

ÀýÈ磺

SELECT @@version;

µÇ¼ºó¸´ÖÆ

3. ´æ´¢Àú³Ì²ÎÊý

ÔÚ´æ´¢Àú³ÌÖУ¬@ ·ûºÅÓÃÓÚÉùÃ÷ºÍת´ï²ÎÊý ¡£Ó﷨Ϊ£º

CREATE PROCEDURE procedure_name (
    IN @param_name1 data_type,
    IN @param_name2 data_type,
    ...
);

µÇ¼ºó¸´ÖÆ

ÀýÈ磺

CREATE PROCEDURE GetCustomerOrders (
    IN @customer_id INT
);

µÇ¼ºó¸´ÖÆ

4. ÅÌÎÊ»º´æÖÀÖÐ

@ ·ûºÅ¿ÉÓÃÓÚ¼ì²éÅÌÎÊÊÇ·ñÖÀÖÐÅÌÎÊ»º´æ ¡£Ó﷨Ϊ£º

SELECT /*!@SQL_CACHE*/ * FROM table_name;

µÇ¼ºó¸´ÖÆ

ÈôÊÇÅÌÎÊÖÀÖлº´æ£¬Ôò @SQL_CACHE µÄֵΪ 1£¬²»È»Îª 0 ¡£

5. ½¨ÉèÔÝʱ±í

@ ·ûºÅ¿ÉÓÃÓÚ½¨ÉèÔÝʱ±í ¡£Ó﷨Ϊ£º

CREATE TEMPORARY TABLE table_name (
    column_name1 data_type,
    column_name2 data_type,
    ...
)
;

µÇ¼ºó¸´ÖÆ

ÀýÈ磺

CREATE TEMPORARY TABLE OrderSummary (
    order_id INT,
    product_id INT,
    quantity INT
)
;

µÇ¼ºó¸´ÖÆ

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

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ