LightDB varchar2字节字符长度兼容oracle

功能简介

oracle数据库 varchar2语法样式:
在这里插入图片描述
LightDB 23.1版本在语法层面兼容oracle varchar2;
支持如下语法形式:

  1. varchar2
  2. varchar2(10)
  3. varchar2(10 byte)
  4. varchar2(10 char)
  5. varchar2(10 BYTE)
  6. varchar2(10 CHAR)
  7. varchar2(10 ByTe)
  8. varchar2(10 cHAr)

LightDB varchar2内部已字符来计算长度,无论在建表时指定的是byte或者char或者不指定。

用法

lightdb@postgres=# create table t1(id int, name varchar2(10));
 CREATE TABLE
lightdb@postgres=# insert into t1 values(1, '你好呀,你在干什么呢');
INSERT 0 1
lightdb@postgres=# insert into t1 values(1, '你好呀,你在干什么呢?');
ERROR:  input value length is 11; too long for type varchar2(10)
lightdb@postgres=# insert into t1 values(2, 'abcdefghij');
INSERT 0 1
lightdb@postgres=# insert into t1 values(2, 'abcdefghijk');
ERROR:  input value length is 11; too long for type varchar2(10)
lightdb@postgres=# drop table t1;
DROP TABLE
lightdb@postgres=# 
lightdb@postgres=# create table t2(id int, name varchar2(10 byte));
CREATE TABLE
lightdb@postgres=# insert into t2 values(1, '你好呀,你在干什么呢');
INSERT 0 1
lightdb@postgres=# insert into t2 values(1, '你好呀,你在干什么呢?');
ERROR:  input value length is 11; too long for type varchar2(10)
lightdb@postgres=# insert into t2 values(2, 'abcdefghij');
INSERT 0 1
lightdb@postgres=# insert into t2 values(2, 'abcdefghijk');
ERROR:  input value length is 11; too long for type varchar2(10)
lightdb@postgres=# drop table t2;
DROP TABLE
lightdb@postgres=# 
lightdb@postgres=# create table t3(id int, name varchar2(10 char));
CREATE TABLE
lightdb@postgres=# insert into t3 values(1, '你好呀,你在干什么呢');
INSERT 0 1
lightdb@postgres=# insert into t3 values(1, '你好呀,你在干什么呢?');
ERROR:  input value length is 11; too long for type varchar2(10)
lightdb@postgres=# insert into t3 values(2, 'abcdefghij');
INSERT 0 1
lightdb@postgres=# insert into t3 values(2, 'abcdefghijk');
ERROR:  input value length is 11; too long for type varchar2(10)
lightdb@postgres=# drop table t3;
DROP TABLE
lightdb@postgres=# 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值