Technology of SQL Server database (90)
Tuesday, March 03, 2009 by rain
SQL SERVER offerred use SQL SERVER Enterprise Manager and Transac-SQL to command two kinds of methods will found view.Be being founded or use view,The following condition should notice when:
%26#8226; can found view in current database only,Can cite only at most in view 1024 is listed;
%26#8226; if the watch that view cites is deleted,Will return a wrong message when using this view,If found the structural new list that has identical list to replace the list that already deleted,view criterion can be used,Must found view afresh otherwise;
%26#8226; if row of the some in view is expression of function, maths, constant or the row name that come from many watches identical,Must define a name for the row;
%26#8226; cannot found index on view;View cannot cite in the definition in regular, default, trigger;
When %26#8226; should inquire data through view,Whether does the list that SQL SERVER wants to check view to cite not only exist,Effective,And even logarithm of test and verify occupies revise the integrality that whether disobeyed data to restrain.If failure will return wrong message,If correct,Cite the inquiry changeover to view in couples the inquiry of the watch.
1, use SQL SERVER Enterprise Manager will found view
The measure that in SQL SERVER use SQL SERVER Enterprise Manager founds view is:
(1) starts SQL SERVER Enterprise Manager,The server that logins to appoint;
(2) opens the database folder that should found view,Icon of pitch on View,All view that show current database in the window case of the right side right now,Right attack icon,In option of New View of the choice in playing a menu,Open dialog box of New View.The 13-1 that be like a graph.Four areas are shared in dialog box of New View:Area of watch area, the SQL Script that list an area, data result area (right now four areas in the dialog box are blank) ;
(When 3) is founding view,Click pushbutton above all,Open add watch dialog box,Place of the 13-2 that be like a graph is shown;
(4) chooses to will include to be listed in the data of view in listing an area,Right now script of corresponding SQL SERVER shows in area of SQL Script;
(5) sheet nods pushbutton,Will show in data result area include the data in view to go;
(6) clicks pushbutton,In name of view of the input in shooting a dialog box,Click " to save what " finishs view to found.
2, Transact-SQL command founds view
The syntactic format that use Transact-SQL commands to CREATE VIEW founds view is:
The meaning of each parameter explains as follows:
%26#8226; View_name
Represent view name.
%26#8226; Select_statement
The principal part that makes view text version,Use SELECT to command from the watch medium or the line that the row chooses to make new view in view.
Clew:But in SELECT statement,Cannot use statement of ORDER BY, COMPUTE, COMPUTE BY,Cannot use INTO key word,Cannot use express temporarily.
%26#8226; WITH CHECK OPTION
After assuring to carrying out data to revise to view,Still can see these data through view.Conditional statement was defined when founding view for instance,Apparently the data that view result includes to satisfy a requirement only centrally goes.If be opposite,some one linage is revised according to undertaking,Bring about this record not to satisfy this one requirement,But because option of WITH CHECH OPTION was used when founding view,When inquiring view so,The result still includes this record centrally,Revise at the same time invalid.
%26#8226; ENCRYPTION
Express to undertake adding to view text close,When should examining Syscomments to express so,The value of Txt field that sees is code of a few chaos only.
%26#8226; SCHEMABINDING
Express to if include,be in in Select_statement statement watch, view or cite the user defines function oneself,The person that before expressing name, view name or function name, must have somewhat is prepositive.
%26#8226; VIEW_METADATA
This view cites in if some inquires,expressing and when the requirement returns the metadata of the mode that browse,So the metadata information that SQL Server will return view to DBLIB and OLE DB APIS
Exemple 13-13:Option of use WITH ENCRYPTION WITH CHECK OPTION,And include function list.
Because used WITH CHECK OPTION,When should undertaking modification to view so,Will return wrong message.Carry out the following statement for instance:
Return wrong message to be:
13.10.2 manages view
1, examine, modification view
In SQL SERVER,Basically implement the following measure through SQL SERVER Enterprise Manager is examined and altering view:
(1) starts SQL SERVER Enterprise Manager,The server that logins to appoint;
(2) opens the database folder that should found view,Icon of pitch on View,All view that show current database in the window case of the right side right now;
(3) is right attack the view that should examine,In option of Properties of the choice in playing a menu,Open dialog box of View Properties,Place of the 13-3 that be like a graph is shown;
(4) in the text that this view can browse inside this dialog box,Also can undertake modification to this view,Click pushbutton of Check Syntax to come next lawful to the statement sex undertakes checking,If want to undertake to the visit attributive of view,install,Click Permissions pushbutton please.
2 uses memory process to check view
The detailed information that process Sp_help uses the system to return concerned database object,If not be aimed at some specific target,All target information in returning a database its grammar is as follows:
Name of object of Sp_help database
The text that systematic process Sp_helptext retrieves process of a view, trigger, memory.Its grammar is:Sp_helptext view (process of trigger, memory)
3 deletes view
Delete view uses DROP to command like deleting a watch.Its grammar is:
DROP VIEW inspects graph name