Creada el: 28/09/98 - Actualizada el: 28/09/98

Guía de Referencia Rápida

Página 1/16
WB01345_.gif (616 bytes)


ALTER DATABASE Statement                                                         
Increases the amount of disk space allocated to a database.                      
                                                                                 
ALTER DATABASE <database_name>                                                   
     [ON {DEFAULT | <database_device>} [= <size>]                                
          [, <database_device> [= <size>]]...]                                   
[FOR LOAD]                                                                       
test                                                                             

ALTER TABLE Statement                                                            
Adds new columns or constraints to an existing table.                            
                                                                                 
ALTER TABLE <database>.[<owner>.]<table_name>                                    
[WITH {CHECK | NOCHECK}]                                                         
{{CHECK | NOCHECK} CONSTRAINT                                                    
{<constraint_name> | ALL} |                                                      
[ADD                                                                             
     {<col_name> <column_properties> [<column_constraints>]                      
     | [[,] <table_constraint>]}                                                 
          [, {<next_col_name> | <next_table_constraint>}]...]                    
|                                                                                
[DROP CONSTRAINT]                                                                
     <constraint_name> [, <constraint_name2>]...]}                               
                                                                                 
<column_properties> =                                                            
     <datatype> [NULL | IDENTITY[(<seed>, <increment>)]]                         
                                                                                 
<column_constraints> =                                                           
  For a column-level constraint:                                                 
    [CONSTRAINT <constraint_name> ]                                              
    {PRIMARY KEY [CLUSTERED | NONCLUSTERED][ (<col_name>)]                       
         | UNIQUE [CLUSTERED | NONCLUSTERED] [(<col_name>)]                      
               [WITH FILLFACTOR = <fillfactor> ]                                 
         | FOREIGN KEY [(<col_name>)]                                            
               REFERENCES [(<ref_col>)][NOT FOR REPLICATION]                     
 		| CHECK [NOT FOR REPLICATION] (<expression>)}                                 
<table_constraints> =                                                            
  For a table-level constraint:                                                  
     [CONSTRAINT <constraint_name> ]                                             
          {PRIMARY KEY [CLUSTERED | NONCLUSTERED]                                
               (<col_name> [, <col_name2> [..., <col_name16>]])                  
          | UNIQUE [CLUSTERED | NONCLUSTERED]                                    
               (<col_name> [, <col_name2> [..., <col_name16>]])                  
               [WITH FILLFACTOR = <fillfactor>]                                  
          | FOREIGN KEY (<col_name> [, <col_name2> [..., <col_name16>]])         
               REFERENCES [<owner>.]<ref_table> (<ref_col>                       
                    [, <ref_col2> [..., <ref_col16>]])                           
               [NOT FOR REPLICATION]                                             
          | CHECK [NOT FOR REPLICATION] (<expression>)}                          

BEGIN DISTRIBUTED TRANSACTION Statement                                          
Used to start a transaction that is processed on one or                          
more remote servers. MS DTC manages the distributed transaction.                 
                                                                                 
BEGIN DISTRIBUTED TRANSACTION [<transaction_name>]                               

BEGIN TRANSACTION Statement                                                      
Marks the starting point of a user-specified transaction.                        
                                                                                 
BEGIN TRANsaction [<transaction_name>]                                           

BEGIN...END Block                                                                
Encloses a series of SQL statements so that control-of-flow language,            
such as IF...ELSE, affects the performance of a group of statements              
instead of only the statement that immediately follows.                          
                                                                                 
BEGIN...END blocks can be nested.                                                
BEGIN                                                                            
     {sql_statement | <statement_block>}                                         
END                                                                              

CASE Expression                                                                  
The CASE expression allows SQL expressions to be simplified for                  
conditional values. The CASE expression in SQL Server 6.0 is ANSI                
SQL-92-compliant and allowed anywhere an expression is used.                     
                                                                                 
Simple CASE expression:                                                          
     CASE <expression>                                                           
          WHEN <expression1> THEN <expression1>                                  
          [[WHEN <expression2> THEN <expression2>] [...]]                        
          [ELSE <expressionN>]                                                   
     END                                                                         
                                                                                 
Searched CASE expression:                                                        
     CASE                                                                        
          WHEN <Boolean_expression1> THEN <expression1>                          
          [[WHEN <Boolean_expression2> THEN <expression2> ] [...]]               
          [ELSE <expressionN>]                                                   
     END                                                                         
                                                                                 
CASE-related functions:                                                          
     COALESCE (<expression1>, <expression2>)                                     
     COALESCE (<expression1>, <expression2>, ... <expressionN>)                  
     NULLIF (<expression1>, <expression2>)                                       
                                                                                 

CHECKPOINT Statement                                                             
Forces all dirty pages (those that have been updated since the                   
last checkpoint) in the current database to be written to disk.                  
                                                                                 
CHECKPOINT                                                                       

CLOSE Statement                                                                  
Closes an open cursor. CLOSE leaves the data structures accessible for           
reopening; however, modifications or fetches are not allowed until the           
cursor is reopened.                                                              
                                                                                 
CLOSE <cursor_name>                                                              

Comments                                                                         
Provide user-documented information about SQL statements, statement              
blocks, and stored procedures.                                                   
/* <text of comment> */                                                          
Or                                                                               
-- <text of comment>                                                             

COMMIT TRANSACTION Statement                                                     
Marks the end of a user-defined transaction.                                     
                                                                                 
COMMIT TRANsaction [<transaction_name>]                                          

Control-of-Flow Language                                                         
Controls the flow of execution of SQL statements, statement blocks, and          
stored procedures. These keywords can be used in ad hoc SQL                      
statements, in batches, and in stored procedures.                                
                                                                                 
These are the control-of-flow keywords:                                          
BEGIN...END      Defines a statement block.                                      
GOTO <label>     Continues processing at the statement following the             
                 label as defined by <label>.                                    
IF...ELSE        Defines conditional and, optionally, alternate                  
                 execution when a condition is false.                            
RETURN           Exits unconditionally.                                          
WAITFOR          Sets a delay for statement execution.                           
WHILE            Repeats statements while a specific condition is true.          
...BREAK         Exits the innermost WHILE loop.                                 
...CONTINUE      Restarts a WHILE loop.                                          
                                                                                 

CREATE DATABASE Statement                                                        
Creates a new database. You must be in the master database to create a           
new database.                                                                    
                                                                                 
CREATE DATABASE <database_name>                                                  
[ON {DEFAULT | <database_device>} [= <size>]                                     
     [, <database_device> [= <size>]]...]                                        
[LOG ON <database_device> [= <size>]                                             
     [, <database_device> [= <size>]]...]                                        
[FOR LOAD]                                                                       
                                                                                 

CREATE DEFAULT Statement                                                         
Creates an object that, when bound to a column or a user-defined                 
datatype, specifies a value to be inserted into the column to which it's         
bound (or into all columns in the case of a user-defined datatype) when          
no value is explicitly supplied during an insert.                                
                                                                                 
CREATE DEFAULT [<owner>.]<<default_name>>                                        
AS <constant_expression>                                                         

CREATE INDEX Statement                                                           
Creates an index on a given table that either changes the physical               
ordering of the table or provides the optimizer with a logical ordering          
of the table to increase efficiency for queries.                                 
                                                                                 
CREATE [UNIQUE] [CLUSTERED | NONCLUSTERED] INDEX <index_name>                    
     ON [[<database>.]<owner>.]<table_name> (<column_name>                       
          [, <column_name>]...)                                                  
[WITH                                                                            
     [PAD_INDEX,]                                                                
     [[,]FILLFACTOR = <fillfactor>]                                              
     [[,] IGNORE_DUP_KEY]                                                        
     [[,] SORTED_DATA | SORTED_DATA_REORG]                                       
     [[,] IGNORE_DUP_ROW | ALLOW_DUP_ROW]]                                       
[ON <segment_name>]                                                              
                                                   
Página 1/16
WB01345_.gif (616 bytes)

Página Inicial

Por Luis Walter Reynoso para Ethek & Friends