OracleParameter.Size 属性


获取或设置列中的数据的最大大小(以字节为单位)。Gets or sets the maximum size, in bytes, of the data within the column.

 property int Size { int get(); void set(int value); };
 virtual property int Size { int get(); void set(int value); };
public int Size { get; set; }
public override int Size { get; set; }
member this.Size : int with get, set
Public Property Size As Integer
Public Overrides Property Size As Integer


列中的数据的最大大小(以字节为单位)。The maximum size, in bytes, of the data within the column. 默认值为 0(在不想指定最大值时使用)。The default value is 0 (to be used when you do not want to specify the maximum size of the value).



下面的示例创建一个 OracleParameter 并设置其一些属性。The following example creates a OracleParameter and sets some of its properties.

Public Sub CreateOracleParameter()  
   Dim parameter As New OracleParameter("pDescription", OracleType.VarChar)  
   parameter.IsNullable = True  
   parameter.Direction = ParameterDirection.Output  
   parameter.Size = 88  
End Sub  
public void CreateOracleParameter()   
   OracleParameter parameter = new OracleParameter("pDescription", OracleType.VarChar);  
   parameter.IsNullable = true;  
   parameter.Direction = ParameterDirection.Output;  
   parameter.Size = 88;  


设置 Size 仅影响参数的输入值。Setting Size affects only the input value of a parameter. 此属性不影响返回值和输出参数。Return values and output parameters are not affected by this property.

Size 属性用于二进制和字符串类型。The Size property is used for binary and string types.

对于非字符串数据类型和 ANSI 字符串数据,Size 属性是指字节数。For nonstring data types and ANSI string data, the Size property refers to the number of bytes. 对于 Unicode 字符串数据,Size 是指字符数。For Unicode string data, Size refers to the number of characters. 字符串的计数不包括终止字符。The count for strings does not include the terminating character.

对于可变长度数据类型,Size 描述要传输到服务器的最大数据量。For variable-length data types, Size describes the maximum amount of data to transmit to the server. 例如,对于 Unicode 字符串值,可以使用 Size 将发送到服务器的数据量限制为前100个字符。For example, for a Unicode string value, Size could be used to limit the amount of data sent to the server to the first one hundred characters.

对于双向参数、输出参数和返回值,必须设置大小的值。For bidirectional and output parameters, and return values, you must set the value of Size. 这不是输入参数所必需的,如果未显式设置,则执行参数化语句时,的值将从指定参数的实际大小推断。This is not required for input parameters, and if not explicitly set, the value of is inferred from the actual size of the specified parameter when a parameterized statement is executed.

可以通过设置 Value来推断参数的 DbTypeOracleTypeSize 属性。The DbType, OracleType, and Size properties of a parameter can be inferred by setting Value. 因此,您不需要指定它们。Therefore, you are not required to specify them. 但是,它们不 OracleParameter 属性设置公开。However, they are not exposed in OracleParameter property settings. 例如,如果已推断出参数的大小,则在语句执行后 Size 不包含推断值。For example, if the size of the parameter has been inferred, Size does not contain inferred value after statement execution.

对于固定长度数据类型,将忽略 Size 的值。For fixed length data types, the value of Size is ignored. 可以检索它以提供信息,并返回将参数值传输到服务器时提供程序使用的最大字节数。It can be retrieved for informational purposes, and returns the maximum amount of bytes the provider uses when transmitting the value of the parameter to the server.