MySQLÖеÄCREATE VIEWÓï·¨
CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
¸ÃÓï¾äÄÜ´´½¨ÐµÄÊÓͼ£¬Èç¹û¸ø¶¨ÁËOR REPLACE×Ӿ䣬¸ÃÓï¾ä»¹ÄÜÌæ»»ÒÑÓеÄÊÓͼ¡£select_statementÊÇÒ»ÖÖSELECTÓï¾ä£¬Ëü¸ø³öÁËÊÓͼµÄ¶¨Òå¡£¸ÃÓï¾ä¿É´Ó»ù±í»òÆäËûÊÓͼ½øÐÐÑ¡Ôñ¡£
¸ÃÓï¾äÒªÇó¾ßÓÐÕë¶ÔÊÓͼµÄCREATE VIEWȨÏÞ£¬ÒÔ¼°Õë¶ÔÓÉSELECTÓï¾äÑ¡ÔñµÄÿһÁÐÉϵÄijЩȨÏÞ¡£¶ÔÓÚÔÚSELECTÓï¾äÖÐÆäËûµØ·½Ê¹ÓõÄÁУ¬±ØÐë¾ßÓÐSELECTȨÏÞ¡£Èç¹û»¹ÓÐOR REPLACE×Ӿ䣬±ØÐëÔÚÊÓͼÉϾßÓÐDROPȨÏÞ¡£
ÊÓͼÊôÓÚÊý¾Ý¿â¡£ÔÚĬÈÏÇé¿öÏ£¬½«ÔÚµ±Ç°Êý¾Ý¿â´´½¨ÐÂÊÓͼ¡£ÒªÏëÔÚ¸ø¶¨Êý¾Ý¿âÖÐÃ÷È·´´½¨ÊÓͼ£¬´´½¨Ê±£¬Ó¦½«Ãû³ÆÖ¸¶¨Îªdb_name.view_name¡£
mysql> CREATE VIEW test.v AS SELECT * from t;
±íºÍÊÓͼ¹²ÏíÊý¾Ý¿âÖÐÏàͬµÄÃû³Æ¿Õ¼ä£¬Òò´Ë£¬Êý¾Ý¿â²»ÄÜ°üº¬¾ßÓÐÏàͬÃû³ÆµÄ±íºÍÊÓͼ¡£
ÊÓͼ±ØÐë¾ßÓÐΨһµÄÁÐÃû£¬²»µÃÓÐÖظ´£¬¾ÍÏñ»ù±íÄÇÑù¡£Ä¬ÈÏÇé¿öÏ£¬ÓÉSELECTÓï¾ä¼ìË÷µÄÁÐÃû½«ÓÃ×÷ÊÓͼÁÐÃû¡£ÒªÏëΪÊÓͼÁж¨ÒåÃ÷È·µÄÃû³Æ£¬¿ÉʹÓÿÉÑ¡µÄcolumn_list×Ӿ䣬ÁгöÓɶººÅ¸ô¿ªµÄID¡£column_listÖеÄÃû³ÆÊýÄ¿±ØÐëµÈÓÚSELECTÓï¾ä¼ìË÷µÄÁÐÊý¡£
SELECTÓï¾ä¼ìË÷µÄÁпÉÒÔÊǶԱíÁеļòµ¥ÒýÓá£Ò²¿ÉÒÔÊÇʹÓú¯Êý¡¢³£Á¿Öµ¡¢²Ù×÷·ûµÈµÄ±í´ïʽ¡£
¶ÔÓÚSELECTÓï¾äÖв»ºÏ¸ñµÄ±í»òÊÓͼ£¬½«¸ù¾ÝĬÈϵÄÊý¾Ý¿â½øÐнâÊÍ¡£Í¨¹ýÓÃÇ¡µ±µÄÊý¾Ý¿âÃû³ÆÏÞ¶¨±í»òÊÓͼÃû£¬ÊÓͼÄܹ»ÒýÓñí»òÆäËûÊý¾Ý¿âÖеÄÊÓͼ¡£
Äܹ»Ê¹ÓöàÖÖSELECTÓï¾ä´´½¨ÊÓͼ¡£ÊÓͼÄܹ»ÒýÓûù±í»òÆäËûÊÓͼ¡£ËüÄÜʹÓÃÁªºÏ¡¢UNIONºÍ×Ó²éѯ¡£SELECTÉõÖÁ²»ÐèÒýÓÃÈÎºÎ±í¡£ÔÚÏÂÃæµÄʾÀýÖУ¬¶¨ÒåÁË´ÓÁíÒ»±íÑ¡ÔñÁ½ÁеÄÊÓͼ£¬²¢¸ø³öÁ˸ù¾ÝÕâЩÁмÆËãµÄ±í´ïʽ£º
mysql> CREATE TABLE t (qty INT, price INT);
mysql> INSERT INTO t VALUES(3, 50);
mysql> CREATE VIEW v AS SELECT qty, price, qty*price AS value from t;
mysql> SELECT * from v;
+------+-------+-------+
| qty | price | value |
+------+-------+-------+
| 3 | 50 | 150 |
+------+-------+-------+
ÊÓͼ¶¨Òå·þ´ÓÏÂÊöÏÞÖÆ£º
· SELECTÓï¾ä²»ÄÜ°üº¬from×Ó¾äÖеÄ×Ó²éѯ¡£
· &n
Ïà¹ØÎĵµ£º
mysql Êý¾Ý¿âĬÈϵÄÁ¬½ÓÖ»ÄÜÔÚ±¾»úÁ¬½Ó£¬Ô¶³ÌÁ¬½Ó±ØÐëÊÚȨ¡£
´úÂë: È«Ñ¡
¡¡GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED
BY 'mypassword' WITH GRANT
OPTION;Èç¹ûÄãÏëÔÊÐíÓû§myuser´ÓipΪ192.168.1.6µÄÖ÷»úÁ¬½Óµ½mysql·þÎñÆ÷£¬²¢Ê¹ÓÃ
mypassword×÷ΪÃÜÂë
´úÂë: GRANT ALL PR ......
groupadd mysql
н¨Ò»¸öÃûΪmysqlµÄÓû§×é
useradd -g mysql mysql
ÔÚmysqlÓû§×éÏÂн¨Ò»¸öÃûΪmysqlµÄÓû§
gunzip ½âѹÏÂÔص½µÄ.gzÎļþ
cd mysql-VERSION
½øÈë½âѹºóµÄĿ¼
CFLAGS="-O3 -mcpu=pentium4" CXX=gcc CXXFLAGS="-O3 -march=pentium4 -felide-constructors -fno-exceptions -fno-rtti" ./configu ......
MySQL·þÎñÆ÷°üº¬Ò»Ð©ÆäËûSQL DBMSÖв»¾ß±¸µÄÀ©Õ¹¡£×¢Ò⣬Èç¹ûʹÓÃÁËËüÃÇ£¬½«ÎÞ·¨°Ñ´úÂëÒÆÖ²µ½ÆäËûSQL·þÎñÆ÷¡£ÔÚijЩÇé¿öÏ£¬Äã¿ÉÒÔ±àд°üº¬MySQLÀ©Õ¹µÄ´úÂ룬µ«ÈÔ±£³ÖÆä¿ÉÒÆÖ²ÐÔ£¬·½·¨ÊÇÓÓ/*... */”×¢Ê͵ôÕâЩÀ©Õ¹¡£MySQL·þÎñÆ÷Äܹ»½âÎö²¢Ö´ÐÐ×¢ÊÍÖеĴúÂ룬¾ÍÏñ¶Ô´ýÆäËûMySQLÓï¾äÒ»Ñù£¬µ«ÆäËûSQL·þÎñÆ÷½«ºöÂÔ ......
Ö®ËùÒÔдÕâƪ²©¿Í£¬ÊÇÒòΪǰ¼¸Ìì²ÅÅöµ½ÁËÕâôһ¸öÎÊÌ⣬ÒÔÇ°»¹²»ÖªµÀmysqlÓÐÕâôһ¸öÎÊÌâ¡£
ÎÒÃǵÄϵͳʹÓÃÁËstruts+hibernate£¬Êý¾Ý¿âʹÓõÄÊÇmysql£¬×Ö·û¼¯Í³Ò»Îªutf-8¡£
±¾À´ÒѾÍê³ÉÁË£¬µ«ÊÇϵͳʹÓõÄʱºò£¬·¢ÏÖ²é³öÀ´µÄÈËÃûûÓÐ˳Ðò£¬±¾À´ÒÔΪºÜ¼òµ¥£¬ÔÚ²éѯµÄʱºò£¬Ö¸¶¨°´ÕÕnameÅÅÐò¾Í¿ÉÒÔÁË£¬Æñ֪ʵ¼ÊÒ»×ö²Å·¢Ï ......
//linuxϱàÒëg++ $(mysql_config --cflags) ***.cpp $(mysql_config --libs)
/*mysqlÊý¾Ý¿âÖбíµÄÄÚÈÝ
mysql> select * from maindb;
+------------------+---------+-------------+---------+----------+---------------------+---------------------+---------------------+------------------- ......