Teradata语法树——insert

这里只是简单保存一下Teradata的语法树,希望能对新手有所帮助。

  • Insert
[NONTEMPORAL | temporal_validtime_qualifier] INS[ERT] [INTO] tablename          
                                                                                
  { (expr [..., expr])                                                  }       
  {                                                                     }       
  { [(columnname [..., columnname])] VALUES (expr [..., expr])          }       
  {                                                                     }       
  { DEFAULT VALUES                                                      } ;     
  {                                                                     }       
  { [(columnname [..., columnname])] subquery                           }       
  {     [HASH BY {expression [... , expression] | RANDOM}]              }       
  {     [LOCAL ORDER BY order_spec_list]                                }       
                                                                                
  [error_logging_option] }                                                      
                                                                                
  [normalize_option]                                                            
                                                                                
where                                                                           
                                                                                
error_logging_option is                                                         
                                                                                
   [LOGGING [ALL] ERRORS [error_limit_option]]                                  
                                                                                
error_limit_option is                                                           
                                                                                
   WITH { NO LIMIT | LIMIT of <number> }                                        
                                                                                
temporal_validtime_qualifier is one of the following:                           
                                                                                
   CURRENT VALIDTIME                                                            
                                                                                
   [SEQUENCED] VALIDTIME [<period value expression>]                            
                                                                                
   NONSEQUENCED VALIDTIME                                                       
                                                                                
normalize_option is one of the following:                                       
                                                                                
   WITH NORMALIZE                                                               
                                                                                
   WITH NORMALIZE ON MEETS [AND OVERLAPS]                                       
                                                                                
   WITH NORMALIZE ON OVERLAPS [AND MEETS]                                       
                                                                                
order_spec_list is                                                              
                                                                                
   order_spec [ASC | DESC] [NULLS FIRST|LAST]                                   
              [..., order_spec [ASC | DESC] [NULLS FIRST|LAST]]                 
order_spec is                                                                   
   {expression | VALIDTIME | temporal_fnc}                                      
                                                                                
  • update
[temporal_validtime_qualifier | NONTEMPORAL]                                    
                                                                                
UPD[ATE] tablename [ [AS] aname ]                                               
                                                                                
   [ FROM tname [as_of_clause][ [AS] aname]                                     
                [for_portition_of]                                              
                [... ,tname [as_of_clause][ [AS] aname ] ] ]                    
                            [for_portition_of]                                  
                                                                                
       { columnname                                              }              
   SET {                                                         } = expr       
       { structUDTcolname . attributename [... . attributename ] }              
                                                                                
           { columnname                                              }          
   [ ... , {                                                         } = expr ] 
           { structUDTcolname . attributename [... . attributename ] }          
                                                                                
   [ WHERE condition    ]                                                       
   [                    ] ;                                                     
   [ ALL                ]                                                       
                                                                                
OR  UPSERT Form:                                                                
                                                                                
[validtime_qualifier] UPD[ATE] tablename [ [AS] aname]                          
                                                                                
       { columnname                                              }              
   SET {                                                         } = expr       
       { structUDTcolname . attributename [... . attributename ] }              
                                                                                
           { columnname                                              }          
   [ ... , {                                                         } = expr ] 
           { structUDTcolname . attributename [... . attributename ] }          
                                                                                
   WHERE UPSERT-condition                                                       
   ELSE INS[ERT] [INTO] tablename                                               
           { [VALUES] (expr, [ ... ,expr])                              }       
           { (columnname [ ...,columnname]) VALUES (expr [ ... ,expr])  } ;     
                                                                                
The UPSERT-condition must fully specify the primary index with                  
equality constraint.                                                            
                                                                                
where temporal_validtime_qualifier is any one of the option below,              
       CURRENT VALIDTIME                                                        
       [SEQUENCED] VALIDTIME [<period value expression>]                        
        NONSEQUENCED VALIDTIME                                                  
                                                                                
where validtime_qualifier is any one of the option below,                       
       CURRENT VALIDTIME                                                        
       [ SEQUENCED ] VALIDTIME [ period of applicability ]                      
       NONSEQUENCED VALIDTIME                                                   
                                                                                
where for_portition_of is: FOR PORTION OF derivedpd_column_name FROM date_exp   
                                                                TO   date_exp   
                                                                                
For temporal_qualifier enter help 'temporal qualifier'.                         
                                                                                
  • delete
DELETE - Basic Form                                                             
                                                                                
[ temporal_validtime_qualifier | NONTEMPORAL ]                                  
                                                                                
                                       [ WHERE condition ]                      
DEL[ETE] FROM tablename [as_of_clause] [ [as] name]] [   ] ;                    
                        [for_portition_of]                                      
                                       [ ALL             ]                      
                                                                                
DELETE - With Implied Join                                                      
                                                                                
[ temporal_validtime_qualifier | NONTEMPORAL ]                                  
                                                                                
DEL[ETE] del_tname FROM tname [as_of_clause] [ [AS] aname ]                     
                              [... , tname [as_of_clause] [ [AS] aname ]        
                                                                                
    [WHERE condition ]                                                          
    [                ] ;                                                        
    [ALL             ]                                                          
                                                                                
where temporal_validtime_qualifier is any one of the options below,             
       CURRENT VALIDTIME                                                        
       [SEQUENCED] VALIDTIME [<period value expression>]                        
        NONSEQUENCED VALIDTIME                                                  
                                                                                
where for_portition_of is: FOR PORTION OF derivedpd_column_name FROM date_exp   
                                                                TO   date_exp   
                                                                                
For as_of_clause enter help 'temporal as of'.                                   
                                                                               
  • merge
[validtime_qualifier] MERGE [INTO] tablename [ [AS] aname ]                     
                                                                                
        { VALUES (expr [...,expr]) }                                            
  USING {                          } [AS] source_tname (cname, [...,cname])     
        { ( subquery )             }                                            
                                                                                
  ON match-condition                                                            
                                                                                
  WHEN MATCHED THEN                                                             
    UPD[ATE] SET cname = expr [...,cname = expr]                                
                                                                                
  WHEN NOT MATCHED THEN                                                         
             {                      [VALUES] (expr [...,expr]) }                
    INS[ERT] {                                                 }                
             { (cname [...,cname])   VALUES  (expr [...,expr]) }                
                                                                                
     [LOGGING [ALL] ERRORS [error_limit_option]] ;                              
                                                                                
     Where error_limit_option is                                                
                                                                                
           { NO LIMIT          }                                                
     [WITH {                   }]                                               
           { LIMIT OF <number> }                                                
                                                                                
where:                                                                          
     The match-condition must fully specify the primary index of the            
     target table with equality constraints.                                    
                                                                                
     Either the WHEN MATCHED or the WHEN NOT MATCHED clause may be              
     omitted as long as the other clause of the pair is present.                
                                                                                
where validtime_qualifier is any one of the options below,                      
       CURRENT VALIDTIME                                                        
       [ SEQUENCED ] VALIDTIME [ period of applicability ]                      
       NONSEQUENCED VALIDTIME                          

  • alter table
[NONTEMPORAL] ALTER TABLE [databasename.]tablename [, option [..., option]]     
                                                                                
             { data_type_declaration [data_type_attributes] [INTO cname]  }     
             { data_type_attributes                                       }     
             { compress_option                                            }     
             { NO COMPRESS                                                }     
             {                                                            }     
 [ ADD cname {                   { UNIQUE                               } } ]   
             { [CONSTRAINT name] { PRIMARY KEY                          } }     
             {                   { CHECK (boolean_condition)            } }     
             {                   { references_option                    } }     
             { NULL                                                       }     
           { security_constraint_column_declaration	                 }          
 [ ADD ( cname data_type_declaration [data_type_attributes]                     
        [..., cname data_type_declaration [data_type_attributes]] ) INTO cname ]
 [ ADD [COLUMN | ROW] ( cname data_type_declaration [data_type_attributes]      
          [..., cname data_type_declaration [data_type_attributes]] )           
             [[NO] AUTO COMPRESS] ]                                             
 [ ADD [COLUMN | ROW | SYSTEM] ( cname ) [[NO] AUTO COMPRESS] ]                 
                                                                                
 [ ADD table_period_definition                                                  
                [ADD [COLUMN] { data_type_declaration [data_type_attributes]}   
                 ADD [COLUMN] { data_type_declaration [data_type_attributes]]]  
                                                                                
 [ ADD normalize_option_definition]                                             
 [ ADD SYSTEM VERSIONING]                                                       
                                                                                
 [ DROP NORMALIZE]                                                              
 [ DROP cname ]                                                                 
 [ DROP SYSTEM VERSIONING]                                                      
 [ RENAME cname {AS | TO} cname ]                                               
 [ DROP cname IDENTITY ]                                                        
 [ DROP period_specification]                                                   
                                                                                
 [ {ADD|DROP} [CONSTRAINT name] FOREIGN KEY (cname [..., cname[, PERIOD cname]])
             references_option ]                                                
                                                                                
 [DROP INCONSISTENT REFERENCES]                                                 
                                                                                
 [ADD [cname | CONSTRAINT name] [time_opt] CHECK (boolean_condition)           ]
 [DROP [cname | CONSTRAINT name]   CHECK                                       ]
 [MODIFY [cname | CONSTRAINT name] CHECK (boolean_condition)                   ]
 [DROP CONSTRAINT name                                                         ]
 [ADD [CONSTRAINT name] [time_opt] [UNIQUE | PRIMARY KEY] (cname [..., cname]) ]
 [ ADD [CONSTRAINT name] [time_opt] [UNIQUE | PRIMARY KEY] cname [..., cname[   
                                                       ( WITHOUT OVERLAPS]]) ]  
                                                                                
 [ RELEASE [ DELETED ] ROWS [ AND RESET LOAD IDENTITY ] ];                      
                                                                                
 [ MODIFY [[NOT] UNIQUE] [NO] [PRIMARY [AMP] [INDEX]] [index_name | NOT NAMED]  
     [(primary_index_column_list)]                                              
     [  NOT PARTITIONED                                                         
      | new_partitioning [WITH {DELETE | INSERT [INTO] save_table}]             
      | alter_partitioning_expression [..., alter_partitioning_expression]      
            [WITH {DELETE | INSERT [INTO] save_table}] ] ] ;                    
                                                                                
 [ REVALIDATE PRIMARY [INDEX] [WITH {DELETE | INSERT [INTO] save_table}] ] ;    
                                                                                
 [ TO CURRENT [WITH {DELETE | INSERT [INTO] save_table}] ] ;                    
                                                                                
 [ {SET | RESET} DOWN ] ;                                                       
                                                                                
 [ FROM TIME ZONE = { [ sign] quotestring }, [TIMEDATEWZCONTROL = tdwzctrl_opt] 
                  [, WITH TIME ZONE]] ;                                         
                                                                                
where                                                                           
                                                                                
For data_type_declaration, enter:  HELP 'data_type declarations';               
                                                                                
For data_type_attributes, enter:  HELP 'data_type attributes';                  
                                                                                
compress_option is one of the following:                                        
                                                                                
   [ COMPRESS [NULL | constant | ({NULL | constant} [..., {NULL | constant}])]  
                                                                                
   [COMPRESS USING [dbname.]udfname DECOMPRESS USING [dbname.]udfname]]         
                                                                                
Note:  COMPRESS, COMPRESS USING, DECOMPRESS USING can be mentioned in any order.
                                                                                
normalize_option_definition is                                                  
 NORMALIZE [ALL BUT (cname [..., cname])] ON cname [ON MEETS [OR OVERLAPS]|     
                                                    ON OVERLAPS [OR MEETS]]     
                                                                                
references_option is                                                            
                                                                                
   REFERENCES [WITH [NO] CHECK OPTION] tname [(cname [..., cname])]             
                                                                                
new_partitioning is one of the following:                                       
                                                                                
   PARTITION BY {general_expression |                                           
                 partitioning_expression |                                      
                 column_partitioning}                                           
                                                                                
   PARTITION BY ( column_partitioning                                           
                  [, partitioning_expresion [..., partitioning_expression]] )   
                                                                                
   PARTITION BY ( partitioning_expression [..., partitioning_expression]        
                 [, column_partitioning                                         
                   [, partitioning_expression [..., partitioning_expression]]] )
                                                                                
general_expression is an expression that is not a RANGE_N or CASE_N function    
after removing any enclosing parentheses.                                       
                                                                                
partitioning_expression is one of the following:                                
                                                                                
   range_n_expression [ADD integer]                                             
                                                                                
   case_n_expression [ADD integer]                                              
                                                                                
range_n_expression is expression that is a RANGE_N function after removing      
any enclosing parentheses.                                                      
                                                                                
CASE_n_expression is expression that is a CASE_N function after removing any    
enclosing parentheses.                                                          
                                                                                
column_partitioning is                                                          
                                                                                
   COLUMN  [ [NO] AUTO COMPRESS]                                                
           [ [ALL BUT] ( column_partition [..., column_partition] ) ]           
           [ADD integer]                                                        
                                                                                
column_partition is                                                             
                                                                                
  [ROW|COLUMN] {cname | (cname [..., cname])} [NO AUTO COMPRESS]                
                                                                                
alter__partitioning_expression is one of the following:                         
                                                                                
   DROP RANGE[#Ln] {WHERE partition_conditional_expression | alter_ranges}      
                [ADD RANGE[#Ln] alter_ranges]                                   
                                                                                
   ADD RANGE[#Ln] alter_ranges                                                  
                                                                                
alter_ranges is one the following:                                              
                                                                                
   BETWEEN range [..., range] [, NO RANGE [OR UNKNOWN]] [, UNKNOWN]             
                                                                                
   NO RANGE [OR UNKNOWN]] [, UNKNOWN]                                           
                                                                                
   UNKNOWN                                                                      
                                                                                
range is range_value [AND range_value] [EACH range_size_value]                  
                                                                                
range_value is {value_expression | *}                                           
                                                                                
range_size_value is value_expression                                            
                                                                                
Notes:  partition_conditional_expression must only reference the system-derived 
column PARTITION#Ln (for the corresponding level) or PARTITION (if only one     
level) from the table being altered; subqueries are not allowed in the          
conditions.  Specifying both OR UNKNOWN and UNKNOWN is not allowed.             
                                                                                
security_constraint_column_declaration is                                       
       security-constraint-name CONSTRAINT                                      
       ... [ , security-constraint-name CONSTRAINT]                             
                                                                                
table_period_definition  is                                                     
   {PERIOD FOR  {derived_pd_cname} (cname, cname)}                              
                {SYSTEM_TIME     }                                              
                                                                                
period_specification is                                                         
   {PERIOD FOR {derived_pd_cname}}                                              
               {SYSTEM_TIME     }                                               
option is one of the following (options may be listed in any order):            
                                                                                
   [NO] FALLBACK [PROTECTION]                                                   
                                                                                
   [NO  ]                                                                       
   [    ] [BEFORE] JOURNAL                                                      
   [DUAL]                                                                       
                                                                                
   [NO       ]                                                                  
   [DUAL     ]                                                                  
   [         ]  AFTER JOURNAL                                                   
   [LOCAL    ]                                                                  
   [NOT LOCAL]                                                                  
                                                                                
   WITH JOURNAL TABLE = [databasename.]tablename                                
                                                                                
   CHECKSUM = {DEFAULT | NONE | LOW | MEDIUM | HIGH | ALL | ON | OFF}           
                                                            [IMMEDIATE]         
                                                                                
   { DEFAULT FREESPACE              }                                           
   {                                }                                           
   { FREESPACE = integer [PERCENT]  }                                           
                                                                                
   { DATABLOCKSIZE = {integer | float} [BYTES | KBYTES | KILOBYTES]  }          
   {                                                       }[IMMEDIATE]         
   { [MINIMUM | MAXIMUM | DEFAULT]  DATABLOCKSIZE          }                    
                                                                                
   { MERGEBLOCKRATIO = integer [PERCENT] }                                      
   { DEFAULT MERGEBLOCKRATIO             }                                      
   { NO MERGEBLOCKRATIO                  }                                      
                                                                                
   [WITH [NO] { [CONCURRENT] ISOLATED LOADING } for_dml_level_opt ]             
                                                                                
                                                                                
for_dml_level_opt is                                                            
   [ FOR { INSERT | ALL | NONE } ]                                              
                                                                                
time_opt is is one of the following:                                            
                                                                                
   CURRENT VALIDTIME  [ AND CURRENT TRANSACTIONTIME ]                           
                                                                                
   [ SEQUENCED | NONSEQUENCED] VALIDTIME  [ AND CURRENT TRANSACTIONTIME ]       
                                                                                
   CURRENT TRANSACTIONTIME [ AND CURRENT VALIDTIME ]                            
                                                                                
   CURRENT TRANSACTIONTIME [ AND [ SEQUENCED | NONSEQUENCED] VALIDTIME ]        
                                                                                
  • ALL Key words
DBS SQL COMMANDS:                                                               
                                                                                
ABORT                   ALTER CONSTRAINT                                        
ALTER FUNCTION          ALTER METHOD                                            
ALTER PROCEDURE         ALTER REPLICATION GROUP     ALTER TABLE                 
ALTER TRIGGER           ALTER TYPE                  ALTER ZONE                  
BEGIN LOGGING           BEGIN QUERY LOGGING         BEGIN TRANSACTION           
CALL                    CHECKPOINT                  COLLECT DEMOGRAPHICS        
COLLECT STATISTICS      COMMENT                     COMMIT                      
CREATE AUTHORIZATION    CREATE CAST                 CREATE CONSTRAINT           
CREATE DATABASE         CREATE FUNCTION                                         
CREATE GLOP SET         CREATE HASH INDEX           CREATE INDEX                
CREATE JOIN INDEX       CREATE MACRO                CREATE METHOD               
CREATE ORDERING         CREATE PROCEDURE            CREATE PROFILE              
CREATE REPLICATION GROUP                            CREATE REPLICATION RULESET  
CREATE ROLE             CREATE TABLE                CREATE TRANSFORM            
CREATE TRIGGER          CREATE TYPE                 CREATE USER                 
CREATE VIEW             CREATE ZONE                 DATABASE                    
DELETE                  DELETE DATABASE             DELETE USER                 
DROP AUTHORIZATION      DROP CAST                   DROP CONSTRAINT             
DROP DATABASE           DROP FUNCTION                                           
DROP GLOP SET           DROP INDEX                  DROP JOIN INDEX             
DROP MACRO              DROP METHOD                 DROP ORDERING               
DROP PROCEDURE          DROP PROFILE                DROP REPLICATION GROUP      
DROP REPLICATION RULESET                            DROP ROLE                   
DROP STATISTICS         DROP TABLE                  DROP TRANSFORM              
DROP TRIGGER            DROP TYPE                   DROP VIEW                   
DROP ZONE                                                                       
DUMP EXPLAIN            ECHO                        END LOGGING                 
END QUERY LOGGING       END TRANSACTION             EXECUTE                     
EXPLAIN                 FLUSH QUERY LOGGING         GIVE                        
GRANT                   GRANT LOGON                 HELP                        
HELP STATISTICS         INITIATE INDEX ANALYSIS     INITIATE PARTITION          
ANALYSIS INSERT         INSERT EXPLAIN              LOCKING                     
MODIFY DATABASE         MERGE                       MODIFY PROFILE              
NEW                     MODIFY USER                 RENAME                      
REPLACE CAST            REPLACE AUTHORIZATION       REPLACE FUNCTION            
REPLACE METHOD          REPLACE MACRO               REPLACE ORDERING            
REPLACE TRANSFORM       REPLACE PROCEDURE           REPLACE QUERY LOGGING       
REPLACE REPLICATION RULESET                         REPLACE TRIGGER             
RESTART INDEX ANALYSIS  REPLACE VIEW                REVOKE                      
ROLLBACK                REVOKE LOGON                SELECT                      
SET SESSION             SET ROLE                    SHOW                        
UPDATE                  SHOW DML                    USING                       
SHOW STATISTICS         BEGIN QUERY CAPTURE         END QUERY CAPTURE           
CREATE FOREIGN SERVER   DROP FOREIGN SERVER         ALTER FOREIGN SERVER        
                                                                                
                                                                                
DBS SQL FUNCTIONS:                                                              
                                                                                
ABS                     ADD_MONTHS              ACOS                            
ACOSH                   ARRAY_TO_JSON           ASCII                           
ASIN                    ASINH                   ATAN                            
ATANH                   ATAN2                   AVERAGE                         
BEGIN                   BSON_CHECK                                              
BYTES                   CAST                                                    
CASE_N                  CHAR_LENGTH             CHAR2HEXINT                     
CHARACTERS              CHR                     CONTAINS                        
COS                     COSH                    COUNT                           
CORR                    COVAR_POP               COVAR_SAMP                      
CSUM                    DECODE                  EDITDISTANCE                    
EMPTY_BLOB              EMPTY_CLOB              END                             
EXP                     EXTRACT                 FLOOR                           
FORMAT                  FROM_BYTES              GEOMETRYTOROWS                  
GREATEST                                                                        
HASHAMP                 HASHBAKAMP              HASHBUCKET                      
HASHROW                 INDEX                   INITCAP                         
INSTR                   INTERVAL                JSON_Agg                        
JSON_Check              JSON_Compose            JSONGETVALUE                    
JSON_KEYS               JSONMETADATA            JSON_Table                      
KURTOSIS                LENGTH                  LN                              
LOG                     LOWER                   LAST                            
LAST_DAY                LEAST                   LPAD                            
LTRIM                   LEFT                                                    
MAVG                    MAXIMUM                                                 
MCHARACTERS             MDIFF                   MEETS                           
MINDEX                  MINIMUM                 MLINREG                         
MONTHS_BETWEEN          MSUBSTR                 MSUM                            
NAMED                   NEXT                    NEXT_DAY                        
NGRAM                                                                           
NPATH                   NULLIFZERO              NUMTODSINTERVAL                 
NUMTOYMINTERVAL         NVL                     NVL2                            
NVP                     NVP2JSON                OADD_MONTHS                     
OCTET_LENGTH                                                                    
OREPLACE                OTRANSLATE              P_INTERSECT                     
P_NORMALIZE             PERCENT_RANK            POSITION                        
POWER                   PRECEDES                PRIOR                           
QUANTILE                RANDOM                  RANGE_N                         
RANK                    RDIFF                   REGEXP_INSTR                    
REGEXP_REPLACE          REGEXP_SIMILAR          REGEXP_SUBSTR                   
REGR_AVGX               REGR_AVGY               REGR_COUNT                      
REGR_INTERCEPT          REGR_R2                 REGR_SLOPE                      
REGR_SXX                REGR_SXY                REGR_SYY                        
ROUND                   ROW_NUMBER              RPAD                            
RTRIM                   REVERSE                 RIGHT                           
SIGN                    SIN                                                     
SINH                    SKEW                    SOUNDEX                         
SQRT                    STDDEV_POP              STDDEV_SAMP                     
STRTOK                  SUBSTR                  SUCCEEDS                        
SUM                     TAN                     TANH                            
TITLE                   TO_BYTES                TO_CHAR                         
TO_DATE                 TO_DSINTERVAL           TO_NUMBER                       
TO_TIMESTAMP            TO_TIMESTAMP_TZ         TO_YMINTERVAL                   
TRUNCATE                TRANSLATE               TRANSLATE_CHK                   
TRIM                    TRUNC                   TRYCAST                         
TYPE                                                                            
UPPER                   VARGRAPHIC              VAR_POP                         
VAR_SAMP                WIDTH_BUCKET            XMLAGG                          
XMLCOMMENT              XMLCONCAT               XMLDOCUMENT                     
XMLELEMENT              XMLFOREST               XMLPARSE                        
XMLPI                   XMLQUERY                XMLSERIALIZE                    
XMLTABLE                XMLTEXT                 XMLVALIDATE                     
XMLSPLIT                                                                        
                                                                                

你可能感兴趣的:(学习笔记,Teradata,语法)