数据泵:转换数据
DTS 数据泵是一个 DTS对象,它驱动数据的导入、导出和转换操作。
在执行数据转换、数据驱动查询和并行数据泵任务期间将使用数据泵。执
行这些任务的过程是:在源和目标连接上创建行集合,然后创建数据泵实
例在源和目标间移动这些行。在复制每一行时,将进行转换操作。
下图中,在第二个步骤中,转换数据任务在 Access DB任务和 SQL
Production DB任务之间进行。转换数据任务用连接间的灰色箭头表示。
图 7. 示例:转换数据任务
要定义从源连接收集的数据,可以生成一个转换任务的查询。DTS 支
持参数化查询,参数化查询允许在执行查询时定义查询值。
可以将查询键入任务的“属性”对话框,也可以使用数据转换服务查
询设计器,它是一个用图形化方式生成 DTS任务查询的工具。下图中,使
用查询设计器来生成一个查询,该查询联接 pubs 数据库中的三个表。
图 8. 数据转换服务查询设计器界面
在转换任务中,还可以定义要对数据进行的更改。下表说明 DTS提供
的内置转换。
转换 说明
复制列 用于在不应用任何转换的情况下将数据直接从源列复制到目标列。
ActiveX 脚本 用于生成自定义转换。请注意,因为转换将逐行进行,ActiveX 脚本可能影响 DTS 软件包的执行速度。
DateTime 字符串 用于将源列中的日期或时间转换为目标列中的另一种格式。
小写字符串 用于将源列转换为小写字符形式,如需要,将其转换为目标数据类型。
大写字符串 用于将源列转换为全大写字符形式,如需要,将其转换为目标数据类型。
中间字符串 用于从源列抽取子字符串,对其进行转换后将结果复制到目标列。
修剪字符串 用于删除源列中字符串的前导空格、尾随空格和嵌入空格,然后将结果复制到目标列。
读取文件 用于打开文件内容(文件名称在源列中指定),然后将内容复制到目标列。
写入文件 用于将源列(数据列)的内容复制到一个文件中,该文件的路径由第二个源列(文件名列)指定。
还可以用编程方式创建自己的自定义转换。生成自定义转换最快速的
方式是使用活动模板库(ATL )自定义转换模板,SQL Server 2000 DTS
样本程序中包括该模板。
数据泵错误记录
SQL Server 2000 中提供了一种记录转换错误的新方法。可以定义三
种异常情况记录文件来记录软件包执行期间的情况:错误文本文件、源错
误行文件和目标错误行文件。
●一般错误信息将写入错误文本文件中。
●如果转换失败,源行出现错误,该行将写入源错误行文件。
●如果插入失败,目标行出现错误,该行将写入目标错误行文件。
在转换数据的任务中将定义异常情况日志文件。每个转换任务都有自
己的日志文件。
数据泵阶段
默认情况下,数据泵有一个阶段,即行转换。该阶段是在未选择阶段
的情况下,在转换数据任务、数据驱动查询任务和并行数据泵任务中映射
列一级的转换时配置的。
多个数据泵阶段是 SQL Server 2000中新增的。通过在 SQL Server
企业管理器中选择多阶段数据泵选项,在数据泵操作过程中的不同阶段都
可以访问数据泵并添加功能。
将数据行从源复制到目标时,数据泵将按照下图中所显示的基本进程
进行操作。
图 9. 数据泵进程
数据泵处理完最后一行数据后,任务结束,数据泵操作终止。
如果高级用户要向软件包添加功能,以便软件包能支持任何数据泵阶
段,可以执行以下操作:
●为每个要自定义的数据泵阶段编写一个 ActiveX 脚本阶段函数。如果
使用 ActiveX 脚本函数来自定义数据泵阶段,不需要该软件包以外的
其它任何代码。
●使用 Microsoft Visual C++? 创建 COM 对象来自定义所选的数据泵阶
段。在该软件包之外开发此程序,在执行转换过程中每个所选的阶段时
将调用该程序。访问数据泵阶段的 ActiveX 脚本方法中每个所选阶段
都使用不同的函数和输入点;而这种方法则不同,它在数据泵任务执行
期间提供一个单一输入点,该输入点将被多个数据泵阶段调用。
保存 DTS 软件包的选项
以下选项可用于保存 DTS 软件包:
●Microsoft SQL Server
如果要将软件包存储到网络中 SQL Server 的任意实例上,该选项将
DTS 软件包保存到 Microsoft SQL Server ,保留一个便于使用的这些软
件包的清单,并在软件包开发进程中添加和删除软件包版本。
●SQL Server 2000 元数据服务
如果准备跟踪软件包版本、元数据和数据系列信息,该选项将 DTS软
件包保存到元数据服务。
●结构化存储文件
如希望在网络间复制、移动和发送软件包而不必将其存储在Microsoft
SQL Server数据库中,该选项将 DTS软件包保存到结构化存储文件。
●Microsoft Visual Basic
如果要将 DTS软件包合并到 Visual Basic 程序中或将其用作 DTS应
用程序开发的原型,该选项将通过 DTS设计器或 DTS导入/ 导出向导所创
建的 DTS软件包保存到 Microsoft Visual Basic 文件。
DTS 作为应用程序开发平台
DTS 设计器为数据移动任务提供了多种解决方案。因为提供通过编程
方式访问 DTS对象模型的功能,DTS 扩展了可用的解决方案的数目。使用
Microsoft Visual Basic、Microsoft Visual C++或任何其它支持 COM的
应用程序开发系统,都可以使用图形化工具所不支持的功能开发出适合于
您的环境的自定义 DTS解决方案。
DTS 为开发人员提供多种不同方式的支持:
●生成软件包
无需使用 DTS设计器或 DTS导入/ 导出向导,您就可以开发极为复杂
的软件包,并可访问对象模型中的全套功能。
●扩展软件包
通过构建自定义任务和转换,可以添加一些适用于您的业务并可在 DTS
内重复使用的新功能。
●执行程序包
并非一定要使用所提供的工具来执行 DTS软件包,可以用编程方式执
行DTS软件包并通过 COM事件显示进度,并允许构建嵌入的或自定义的DTS
执行环境。
样本DTS程序有助于了解DTS编程的入门知识。该样本可与SQL Server
2000一起安装。
如果开发 DTS应用程序,可以重新分发 DTS文件。有关详细信息,请
参阅 SQL Server 2000光盘上的 Redist.txt。

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Zend Studio 13.0.1
Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
