SQL statement handbook (25) Create View

  As of Table (Views) can be regarded as a virtual form.    It's different with the form, the form in the actual data storage, and the concept form, as in the table above is to establish a framework, which itself is not the actual data storage. 

  As the establishment of a table of the grammar are as follows: 


  "SQL statements" could be any one of us in this material is referred to the SQL. 

  Look at an example.    Assume that we have the following form: 

  TABLE Customer 
  (First_Name char (50), 
  Last_Name char (50), 
  Address char (50), 
  City char (50), 
  Country char (25), 
  Birth_Date date) 

  To this form, including on the establishment of a First_Name, Last_Name, and the Country of these three fields of the table as we enter, 

  CREATE VIEW V_Customer 
  AS SELECT First_Name, Last_Name, Country 
  FROM Customer 

  Now, we have a concept called V_Customer depending on the table: 

  View V_Customer 
  (First_Name char (50), 
  Last_Name char (50), 
  Country char (25)) 

  We also can be used as table concept to connect the two forms.    In this case, users can directly from the concept of a table as she wants to find out the information, rather than by the needs of two different forms of action to do once connected.    The assumption that the following two forms: 

  Store_Information form 

  store_name sales date Los Angeles $ 1500 jan-05-1999 San Francisco $ 300 jan-08-1999 Boston $ 700 jan-08-1999 
  Geography forms 

  region_name store_name East Boston East New York West Los Angeles West San Diego 
  We can use the following instructions to build a region including each (region) sales (sales) of the concept as follows: 

  AS SELECT A1.region_name REGION, SUM (A2.Sales) SALES 
  FROM Geography A1, Store_Information A2 
  WHERE A1.store_name = A2.store_name 
  GROUP BY A1.region_name 

  This has given us a concept called V_REGION_SALES depending on the table.    As this concept contains different regions of the sale, oh.    If we should view this as access to information in the table, we will enter, 



  East $ 700 
  West $ 2050 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
  • DZone
  • Netvouz
  • NewsVine
  • Technorati

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Tags: ,