sqlÖÐfrom dualÊÇʲôÒâ˼
ÔÚ sql ÖУ¬from dual Óï¾ä´ÓÒ»¸öÌØÊâÐéÄâ±í dual ÖмìË÷Ò»ÐÐÒ»ÁеÄÊý¾Ý£¬¸Ã±í½ö°üÀ¨Ò»¸öֵΪ x µÄÐС£Æä³£¼ûÓ÷¨°üÀ¨£º³õʼ»¯ÐòÁС¢²åÈëĬÈÏÖµºÍ×÷Ϊ×ÓÅÌÎÊÖеÄÐéÄâ±í¡£
SQL ÖÐ FROM DUAL µÄ¼ÄÒå
ÔÚ SQL ÖУ¬FROM DUAL Óï¾äÓÃÓÚ´ÓÒ»¸ö³ÆΪ DUAL µÄÌØÊâÐéÄâ±íÖмìË÷Ò»ÐÐÊý¾Ý¡£Õâ¸ö±íÖ»ÓÐÒ»ÐÐÒ»ÁУ¬ÁÐÃûʼÖÕΪ DUMMY£¬²¢ÇÒֵҲʼÖÕΪ X¡£
ʹÓó¡¾°
ÒÔÏÂÊÇһЩʹÓà FROM DUAL µÄ³£¼û³¡¾°£º
³õʼ»¯ÐòÁУº¿ÉÒÔʹÓà FROM DUAL À´³õʼ»¯ÐòÁУ¬ÀýÈ磺
CREATE SEQUENCE my_sequence START WITH 1 INCREMENT BY 1; ALTER SEQUENCE my_sequence OWNED BY my_table.my_column;
µÇ¼ºó¸´ÖÆ
²åÈëĬÈÏÖµ£º¿ÉÒÔʹÓà FROM DUAL Ϊ±íÖеÄÁÐÉèÖÃĬÈÏÖµ£¬ÀýÈ磺
ALTER TABLE my_table ADD COLUMN my_column INT DEFAULT (SELECT 1 FROM DUAL);
µÇ¼ºó¸´ÖÆ
×ÓÅÌÎÊ£ºFROM DUAL ¿ÉÒÔÓÃ×÷×ÓÅÌÎÊÖеÄÐéÄâ±í£¬ÀýÈ磺
SELECT * FROM (SELECT 1 FROM DUAL) AS subquery;
µÇ¼ºó¸´ÖÆ
ʾÀý
ÒÔÏÂÊÇÒ»¸öʹÓà FROM DUAL µÄ¼òÆÓʾÀý£º
SELECT 1 FROM DUAL;
µÇ¼ºó¸´ÖÆ
´ËÅÌÎÊ·µ»ØÒ»ÐÐÒ»ÐÐÊý¾Ý£¬¸ÃÐаüÀ¨Ò»¸öÕûÊýÖµ 1¡£
×¢ÖØ£º
DUAL ±íÊÇÒ»¸öÖ»¶Á±í£¬²»¿ÉÔÚÆäÖвåÈë¡¢¸üлòɾ³ýÊý¾Ý¡£
FROM DUAL ½öÓÃÓÚÀû±ã£¬Ëü²»Ö´ÐÐÈκÎÏÖʵ²Ù×÷¡£ËüʵÖÊÉÏÖ»ÊÇ·µ»ØÒ»¸ö°üÀ¨Ò»ÐÐÊý¾ÝµÄÐéÄâ±í¡£
ÒÔÉϾÍÊÇsqlÖÐfrom dualÊÇʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡