sp_setdefaultdatatypemapping (Transact-SQL)
适用于:SQL Server
将 SQL Server 与非 SQL Server 数据库管理系统(DBMS)之间的现有数据类型映射标记为默认值。 此存储过程在分发服务器上的任何数据库中执行。
语法
sp_setdefaultdatatypemapping
[ [ @mapping_id = ] mapping_id ]
[ , [ @source_dbms = ] N'source_dbms' ]
[ , [ @source_version = ] 'source_version' ]
[ , [ @source_type = ] N'source_type' ]
[ , [ @source_length_min = ] source_length_min ]
[ , [ @source_length_max = ] source_length_max ]
[ , [ @source_precision_min = ] source_precision_min ]
[ , [ @source_precision_max = ] source_precision_max ]
[ , [ @source_scale_min = ] source_scale_min ]
[ , [ @source_scale_max = ] source_scale_max ]
[ , [ @source_nullable = ] source_nullable ]
[ , [ @destination_dbms = ] N'destination_dbms' ]
[ , [ @destination_version = ] 'destination_version' ]
[ , [ @destination_type = ] N'destination_type' ]
[ , [ @destination_length = ] destination_length ]
[ , [ @destination_precision = ] destination_precision ]
[ , [ @destination_scale = ] destination_scale ]
[ , [ @destination_nullable = ] destination_nullable ]
[ ; ]
参数
[ @mapping_id = ] mapping_id
标识现有数据类型映射。 @mapping_id为 int,默认值为 NULL
. 如果指定 @mapping_id,则不需要剩余的参数。
[ @source_dbms = ] N'source_dbms'
从中映射数据类型的 DBMS 的名称。 @source_dbms 为 sysname,可以是以下值之一。
值 | 说明 |
---|---|
MSSQLSERVER |
源是 SQL Server 数据库。 |
ORACLE |
源为 Oracle 数据库。 |
NULL (默认值) |
如果 @mapping_id 为 NULL
,则必须指定此参数。
[ @source_version = ] 'source_version'
源 DBMS 的版本号。 @source_version 为 varchar(10),默认值为 NULL
.
[ @source_type = ] N'source_type'
源 DBMS 中的数据类型。 @source_type为 sysname,默认值为 NULL
. 如果mapping_id为 NULL
,则必须指定此参数。
[ @source_length_min = ] source_length_min
源 DBMS 中数据类型的最小长度。 @source_length_min为 bigint,默认值为 NULL
.
[ @source_length_max = ] source_length_max
源 DBMS 中数据类型的最大长度。 @source_length_max为 bigint,默认值为 NULL
.
[ @source_precision_min = ] source_precision_min
源 DBMS 中数据类型的最小精度。 @source_precision_min为 bigint,默认值为 NULL
.
[ @source_precision_max = ] source_precision_max
源 DBMS 中数据类型的最大精度。 @source_precision_max为 bigint,默认值为 NULL
.
[ @source_scale_min = ] source_scale_min
源 DBMS 中数据类型的最小规模。 @source_scale_min为 int,默认值为 NULL
.
[ @source_scale_max = ] source_scale_max
源 DBMS 中数据类型的最大缩放比例。 @source_scale_max为 int,默认值为 NULL
.
[ @source_nullable = ] source_nullable
指定源 DBMS 中的数据类型是否支持值 NULL
。 @source_nullable为位,默认值为 NULL
. 1
表示 NULL
支持值。
[ @destination_dbms = ] N'destination_dbms'
目标 DBMS 的名称。 @destination_dbms为 sysname,可以是以下值之一。
值 | 说明 |
---|---|
MSSQLSERVER |
目标为 SQL Server 数据库。 |
ORACLE |
目标为 Oracle 数据库。 |
DB2 |
目标为 IBM DB2 数据库。 |
SYBASE |
目标为 Sybase 数据库。 |
NULL (默认值) |
[ @destination_version = ] 'destination_version'
目标 DBMS 的产品版本。 @destination_version为 varchar(10),默认值为 NULL
.
[ @destination_type = ] N'destination_type'
目标 DBMS 中列出的数据类型。 @destination_type为 sysname,默认值为 NULL
.
[ @destination_length = ] destination_length
目标 DBMS 中的数据类型的长度。 @destination_length为 bigint,默认值为 NULL
.
[ @destination_precision = ] destination_precision
目标 DBMS 中的数据类型的精度。 @destination_precision为 bigint,默认值为 NULL
.
[ @destination_scale = ] destination_scale
目标 DBMS 中的数据类型的小数位数。 @destination_scale为 int,默认值为 NULL
.
[ @destination_nullable = ] destination_nullable
指定目标 DBMS 中的数据类型是否支持值 NULL
。 @destination_nullable为位,默认值为 NULL
. 1
表示 NULL
支持值。
返回代码值
0
(成功)或 1
(失败)。
注解
sp_setdefaultdatatypemapping
用于 SQL Server 与非 SQL Server DBMS 之间的所有类型的副本 (replica)。
默认数据类型映射适用于所有包含指定 DBMS 的复制拓扑。
权限
只有 sysadmin 固定服务器角色的成员才能执行sp_setdefaultdatatypemapping
。
相关内容
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈