Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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 alter Óï¾äÓ÷¨,Ìí¼Ó¡¢Ð޸ġ¢É¾³ý×ֶεÈ

À´Ô´£ºhttp://www.blogjava.net/Alpha/archive/2007/07/23/131912.html 
//Ö÷¼ü549830479
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//Ôö¼ÓÒ»¸öÐÂÁÐ549830479
alter table t2 add d timestamp;
alter table infos add ......

mysql Êý¾Ý´æ´¢×ܽá

ÓÉÓÚ×î½üÒ»Ö±ÔÚÁ˽âmysql¡£¸÷ÖÖ±íÀàÐ͵ÄÊý¾Ý´æ´¢ÒÔ¼°Ïà¹ØÏÞÖƾÍÊDZØÐëÁ˽âµÄ·½ÃæÁË¡£
×Ô¼ºµÄ·þÎñÆ÷»·¾³£ºOS Cent OS ext3£¬memory 4G£¬ disk 2T block size 4K¡£
¾­µ÷²é£¬linuxÏÂÎļþ×î´óÊÇ´æÔÚÏÞÖƵġ£È¥googleÉÏËÑÁËËÑ£¬´ó¼Ò˵·¨²»Ò»£¬×îÖÕ×Ô¼º»¹ÊÇÕÒµ½±È½Ï¹Ù·½µÄ˵¡£Ïê¼ûhttp://en.wikipedia.org/wiki/Ext3 ËùÒÔ× ......

mysqlÍâ¼üµÄʹÓÃ

ÏñMySQLÕâÑùµÄ¹ØϵÐÍÊý¾Ý¿â¹ÜÀíϵͳ£¬ËüÃǵĻù´¡ÊÇÔÚÊý¾Ý¿âµÄ±íÖ®¼ä´´½¨¹ØϵµÄÄÜÁ¦¡£Í¨¹ý·½±ãµØÔÚ²»Í¬±íÖн¨Á¢¼Ç¼µ½¼Ç¼µÄÁªÏµ£¬RDBMS¿ÉÒÔÀûÓò»Í¬µÄ·½·¨·ÖÎöÊý¾Ý£¬Í¬Ê±±£³ÖÊý¾Ý¿âÒÔϵͳµÄ·½Ê½¡¢×îСµÄÈßÓà½øÐÐ×éÖ¯¡£
¼òµ¥ÃèÊö£º
ÕâЩ¹Øϵ»ù±¾ÉÏÒÀ¿¿Íâ¼ü½øÐйÜÀí£¬ÔÚ¹ØϵÖÐËùÓбíÖоßÓÐÏàͬº¬ÒåµÄ×Ö¶Î×÷Ϊ¹«¹²²¿·ÖÀ´Á¬½Ó ......

Mysql ʱ¼äº¯Êý»ã×Ü

 Ò»¡¢MySQL »ñµÃµ±Ç°ÈÕÆÚʱ¼ä º¯Êý
1.1 »ñµÃµ±Ç°ÈÕÆÚ+ʱ¼ä£¨date + time£©º¯Êý£ºnow()
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+
³ýÁË now() º¯ÊýÄÜ»ñµÃµ±Ç°µÄÈÕÆÚʱ¼äÍ⣬MySQL Öл¹ÓÐÏÂÃæµÄº¯Êý£º
current_tim ......

MyEclipse Á¬½ÓÔ¶³ÌµÄ MYSQL

mysql Êý¾Ý¿âĬÈϵÄÁ¬½ÓÖ»ÄÜÔÚ±¾»úÁ¬½Ó£¬Ô¶³ÌÁ¬½Ó±ØÐëÊÚȨ¡£
´úÂë: È«Ñ¡
¡¡GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED
BY 'mypassword' WITH GRANT
OPTION;Èç¹ûÄãÏëÔÊÐíÓû§myuser´ÓipΪ192.168.1.6µÄÖ÷»úÁ¬½Óµ½mysql·þÎñÆ÷£¬²¢Ê¹ÓÃ
mypassword×÷ΪÃÜÂë
´úÂë:      GRANT ALL PR ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ