简体   繁体   English

如何在Teradata SQL帮助中将表的数据导出为插入查询

[英]How to export data of a table as insert query in Teradata SQL assistance

I am new to Teradata. 我是Teradata的新手。 I have a table that consists of around 600 records. 我有一个包含约600条记录的表。 I want to get the insert query of these records. 我想获取这些记录的插入查询。 In oracle SQL developer i used to export it and there was an option as "insert query". 在oracle SQL开发人员中,我曾经将其导出,并且有一个选项“插入查询”。 How do i achieve this in Teradata SQL assistance? 我如何在Teradata SQL帮助中实现这一目标?

Thanks in advance 提前致谢

There's no built-in way to get INSERTs for all the rows in a result set using SQL Assistant. 没有使用SQL Assistant为结果集中的所有行获取INSERT的内置方法。

There's an ugly workaround using the CSV -UDF like: 使用CSV -UDF有一个丑陋的解决方法,例如:

WITH cte AS 
 (  -- put your select here
   SELECT * FROM dbc.tablesV
 )
SELECT * 
FROM TABLE
 (CSV(NEW VARIANT_TYPE( -- you need to list each column of your table
       cte.DataBaseName                  
      ,cte.TABLENAME                     
      ,cte.Version                       
      ,cte.TableKind                     
      ,cte.ProtectionType                
      ,cte.JournalFlag                   
      ,cte.CreatorName                   
      ,cte.RequestText                   
      ,cte.CommentString                 
      ,cte.ParentCount                   
      ,cte.ChildCount                    
      ,cte.NamedTblCheckCount            
      ,cte.UnnamedTblCheckExist          
      ,cte.PrimaryKeyIndexId             
      ,cte.RepStatus                     
      ,cte.CreateTimeStamp               
      ,cte.LastAlterName                 
      ,cte.LastAlterTimeStamp            
      ,cte.RequestTxtOverflow            
      ,cte.AccessCount                   
      ,cte.LastAccessTimeStamp           
      ,cte.UtilVersion                   
      ,cte.QueueFlag                     
      ,cte.CommitOpt                     
      ,cte.TransLog                      
      ,cte.CheckOpt                      
      ,cte.TemporalProperty              
      ,cte.ResolvedCurrent_Date          
      ,cte.ResolvedCurrent_Timestamp     
      ,cte.SystemDefinedJI               
      ,cte.VTQualifier                   
      ,cte.TTQualifier                   
      ,cte.PIColumnCount                 
      ,cte.PartitioningLevels            
      ,cte.LoadProperty                  
      ,cte.CurrentLoadId                 
      ,cte.LoadIdLayout                  
      ,cte.DelayedJI                     
     ), ',', '"')
   RETURNS (op VARCHAR(32000) CHARACTER SET UNICODE)
 ) AS dt;

Otherwise you must use a different tool... 否则,您必须使用其他工具...

Since you only have 600 records, wouldn't it be easier just to export from SQL*Assistant into Excel or Access and manipulate them using Office tools. 由于您只有600条记录,因此仅将SQL * Assistant导出到Excel或Access并使用Office工具对其进行操作会不会更容易。

Another alternative - connect Teradata as a linked server in SQL Server Management Studio and use the function "script as insert" from inside of it. 另一种选择-将Teradata连接为SQL Server Management Studio中的链接服务器,并从其内部使用“脚本作为插入”功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM