SQL VIEW£¨ÊÓͼ£©
ÊÓͼÊÇ¿ÉÊÓ»¯µÄ±í¡£
±¾Õ½²½âÈçºÎ´´½¨¡¢¸üкÍɾ³ýÊÓͼ¡£
SQL CREATE VIEW Óï¾ä
ʲôÊÇÊÓͼ£¿
ÔÚ SQL ÖУ¬ÊÓͼÊÇ»ùÓÚ SQL Óï¾äµÄ½á¹û¼¯µÄ¿ÉÊÓ»¯µÄ±í¡£
ÊÓͼ°üº¬ÐкÍÁУ¬¾ÍÏñÒ»¸öÕæʵµÄ±í¡£ÊÓͼÖеÄ×ֶξÍÊÇÀ´×ÔÒ»¸ö»ò¶à¸öÊý¾Ý¿âÖеÄÕæʵµÄ±íÖеÄ×ֶΡ£ÎÒÃÇ¿ÉÒÔÏòÊÓͼÌí¼Ó SQL º¯Êý¡¢WHERE ÒÔ¼° JOIN Óï¾ä£¬ÎÒÃÇÒ²¿ÉÒÔÌá½»Êý¾Ý£¬¾ÍÏñÕâЩÀ´×ÔÓÚij¸öµ¥Ò»µÄ±í¡£
×¢ÊÍ£ºÊý¾Ý¿âµÄÉè¼ÆºÍ½á¹¹²»»áÊܵ½ÊÓͼÖеĺ¯Êý¡¢where »ò join Óï¾äµÄÓ°Ïì¡£
SQL CREATE VIEW Óï·¨
CREATE VIEW view_name AS
SELECT column_name(s)
from table_name
WHERE condition
×¢ÊÍ£ºÊÓͼ×ÜÊÇÏÔʾ×î½üµÄÊý¾Ý¡£Ã¿µ±Óû§²éѯÊÓͼʱ£¬Êý¾Ý¿âÒýÇæͨ¹ýʹÓà SQL Óï¾äÀ´Öؽ¨Êý¾Ý¡£
SQL CREATE VIEW ʵÀý
¿ÉÒÔ´Óij¸ö²éѯÄÚ²¿¡¢Ä³¸ö´æ´¢¹ý³ÌÄÚ²¿£¬»òÕß´ÓÁíÒ»¸öÊÓͼÄÚ²¿À´Ê¹ÓÃÊÓͼ¡£Í¨¹ýÏòÊÓͼÌí¼Óº¯Êý¡¢join µÈµÈ£¬ÎÒÃÇ¿ÉÒÔÏòÓû§¾«È·µØÌá½»ÎÒÃÇÏ£ÍûÌá½»µÄÊý¾Ý¡£
Ñù±¾Êý¾Ý¿â Northwind ÓµÓÐһЩ±»Ä¬ÈÏ°²×°µÄÊÓͼ¡£ÊÓͼ "Current Product List" »á´Ó Products ±íÁгöËùÓÐÕýÔÚʹÓõIJúÆ·¡£Õâ¸öÊÓͼʹÓÃÏÂÁÐ SQL ´´½¨£º
CREATE VIEW [Current Product List] AS
SELECT ProductID,ProductName
from Products
WHERE Discontinued=No
ÎÒÃÇ¿ÉÒÔ²éѯÉÏÃæÕâ¸öÊÓͼ£º
SELECT * from [Current Product List]
Northwind Ñù±¾Êý¾Ý¿âµÄÁíÒ»¸öÊÓͼ»áÑ¡È¡ Products ±íÖÐËùÓе¥Î»¼Û¸ñ¸ßÓÚƽ¾ùµ¥Î»¼Û¸ñµÄ²úÆ·£º
CREATE VIEW [Products Above Average Price] AS
SELECT ProductName,UnitPrice
from Products
WHERE UnitPrice>(SELECT AVG(UnitPrice) from Products)
ÎÒÃÇ¿ÉÒÔÏñÕâÑù²éѯÉÏÃæÕâ¸öÊÓͼ£º
SELECT * from [Products Above Average Price]
ÁíÒ»¸öÀ´×Ô Northwind Êý¾Ý¿âµÄÊÓͼʵÀý»á¼ÆËãÔÚ 1997 Äêÿ¸öÖÖÀàµÄÏúÊÛ×ÜÊý¡£Çë×¢Ò⣬Õâ¸öÊÓͼ»á´ÓÁíÒ»¸öÃûΪ "Product Sales for 1997" µÄÊÓͼÄÇÀïÑ¡È¡Êý¾Ý£º
CREATE VIEW [Category Sales For 1997] AS
SELECT DISTINCT CategoryName,Sum(ProductSales) AS CategorySales
from [Product Sales for 1997]
GROUP BY CategoryName
ÎÒÃÇ¿ÉÒÔÏñÕâÑù²éѯÉÏÃæÕâ¸öÊÓͼ£º
SELECT * from [Category Sales For 1997]
ÎÒÃÇÒ²¿ÉÒÔÏò²éѯÌí¼ÓÌõ¼þ¡£ÏÖÔÚ£¬ÎÒÃǽö½öÐèÒª²é¿´ "Beverages" ÀàµÄÈ«²¿ÏúÁ¿£º
SELECT * from [Category Sales For 1997]
WHERE CategoryName='Beverages'
SQL ¸üÐÂÊÓͼ
Äú¿ÉÒÔʹÓÃÏÂÃæµÄÓï·¨À´¸üÐÂÊÓÍ
Ïà¹ØÎĵµ£º
MagentoÊÇÔÚZend FrameworkµÄ»ù´¡Éϴ¶øÀ´£¬ÓÐÁ½ÖÖ·½Ê½¿ÉÒÔ´ÓMagentoµÄcollection»ñµÃÕæÕýµÄSQLÓï¾ä¡£
ÒÔ Mage::getResourceModel('reports/product_collection') ΪÀý£º
1
$collection=Mage::getResourceModel('reports/product_collection');
......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Str
{
public partial class Form1 : F ......
MagentoµÄModels
ºÍCollection
ºÜÇ¿´ó£¬Ê¹ÓÃËüÃÇ¿ÉÒԺܷ½±ãµÄ²éѯºÍ²Ù×÷Êý¾Ý¿â¡£µ«ÊÇÓÐЩ³¡ºÏ£¬ÒòΪһЩÌØÊâÐèÇó»ò¶ÔMagentoµÄÁ˽ⲻ¹»É¿ÉÄÜ»áÐèÒª×Ô¼ºÊÖдSQLÓï¾äÀ´²éѯºÍ²Ù×÷Êý¾Ý¿â¡£ÒÔÏ·ֱðÊǶÁдÊý¾Ý¿âµÄ´úÂë¡£
// For Read
// fetch read database connection that is used in Mage_Core modul ......
SQL Server 2008 R2µÄÊ®´ó±ä»¯£¨ÉÏ£©£¬SQL Server 2008 R2µÄÊ®´ó±ä»¯£¨Ï£© ÕâÊ®´óÌØÐÔÖÐÎұȽϸÐÐËȤµÄÊÇStreamInsight£ºÍ¨¹ýSQL Server 2008 R2еÄStreamInsight×é¼þ£¬Microsoft½øÈëÁ˸´ÔÓʼþ´¦Àí(Complex Event Processing£¬CEP)¾ºÕù£¬ÆäÖÐÏà¹ØµÄ¹©Ó¦ÉÌ»¹ÓÐOracle¡¢IBMºÍStreamBase¡£
SQL Server 2008 R2ÒýÈëStreamIn ......
תÔØ×Ô£ºhttp://www.neatstudio.com/index-4.shtml
ÎÄÕÂÀ´×Ô¼Åįhacker,http://hi.baidu.com/isbx/blog/item
/08ef48547ef1ad58574e00bf.html:
µ±Ç°µÄWeb¿ª·¢ÕßÖп϶¨Óв»ÉÙÈËûÓÐ×¢Òâµ½×÷ÕßËùÌáµ½µÄÕâÁ½¸öÎÊÌâµÄ¡£
µÚÒ»¸öÎÊÌâÊÇÕâÑùµÄ£¬MySQLĬÈÏÓÐÒ»¸öÅäÖòÎÊý
max_packet_size£¬Õâ¸ö²ÎÊýÊÇÓÃÓÚÏÞÖÆMySQL¿Í»§¶ËºÍMy ......