【问题标题】:VarChar can be composed of?VarChar可以由什么组成?
【发布时间】:2021-08-21 07:14:43
【问题描述】:

varchar 数据类型可以包含数值和特殊字符吗?
如果是,请详细说明。

【问题讨论】:

标签: oracle sqldatatypes


【解决方案1】:

没有什么我想详细说明的。 Documentation(11g 版本;选择您可能使用的任何其他版本)几乎解释了所有内容:

VARCHAR2 数据类型存储可变长度的字符串。

例子:

SQL> create table test (col varchar2(20));

Table created.

SQL> -- string
SQL> insert into test values ('abc');

1 row created.

SQL> -- number - implicitly converted to varchar2 datatype
SQL> insert into test values (100);

1 row created.

SQL> -- special characters - not exactly "special", as they are enclosed into
SQL> -- single quotes so they are actually treated as "strings", but yes - you
SQL> -- can store them into a varchar2 column as well
SQL> insert into test values ('#$%');

1 row created.

SQL> select * from test;

COL
--------------------
abc
100
#$%

SQL>

【讨论】:

    【解决方案2】:

    它是一种长度不定的字符串数据类型。它可以包含数字、字母和特殊字符。对于 varchar,您需要检查 ASCII 和 EXTENDED ASCII 字符,因为它们在 char/varchar 字段中是允许的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-04
      • 2017-03-05
      • 1970-01-01
      • 2013-03-11
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      • 2018-11-05
      相关资源
      最近更新 更多