lightdb 支持兼容Oracle的to_clob函数

news/2024/7/9 20:25:33 标签: 数据库, postgresql

文章目录

  • 概述
  • 案例演示

概述

在信创移植的SQL语句中,有来源于Oracle数据库的SQL语句。

在ORACLE PL/SQL包中,你可以使用TO_CLOB(character)函数将RAW、CHAR、VARCHAR、VARCHAR2、NCHAR、NVARCHAR2、CLOB值转换为CLOB。

因此在LightDB 23.3版本中实现了对TO_CLOB函数的支持。

案例演示

环境准备

create database test_oracle with lightdb_syntax_compatible_type  oracle;
\c test_oracle

使用TO_CLOB函数

lightdb@test_oracle=# CREATE TABLE testorafce_to_clob (
lightdb@test_oracle(# col_char CHAR(10),
lightdb@test_oracle(# col_varchar2 VARCHAR2(20),
lightdb@test_oracle(# col_varchar VARCHAR(20),
lightdb@test_oracle(# col_nchar NCHAR(10),
lightdb@test_oracle(# col_nvarchar2 NVARCHAR2(20),
lightdb@test_oracle(# col_smallint smallint,
lightdb@test_oracle(# col_integer integer,
lightdb@test_oracle(# col_bigint bigint,
lightdb@test_oracle(# col_decimal decimal,
lightdb@test_oracle(# col_numeric numeric,
lightdb@test_oracle(# col_real real,
lightdb@test_oracle(# col_double double precision,
lightdb@test_oracle(# col_clob CLOB,
lightdb@test_oracle(# col_raw raw(10)
lightdb@test_oracle(# );
CREATE TABLE


lightdb@test_oracle=# INSERT INTO testorafce_to_clob (col_char, col_varchar2, col_varchar, col_nchar, col_nvarchar2, col_smallint, col_integer, col_bigint, col_decimal, col_numeric, col_real, col_double, col_clob, col_raw)
lightdb@test_oracle-# VALUES ('ABC1', 'Hello', 'world', N'中文', N'こんにちは', 1, 2, 3, 4, 5, 6, 7, 'This is a CLOB', 'AB');
INSERT 0 1
lightdb@test_oracle=# INSERT INTO testorafce_to_clob (col_char, col_varchar2, col_varchar, col_nchar, col_nvarchar2, col_smallint, col_integer, col_bigint, col_decimal, col_numeric, col_real, col_double, col_clob, col_raw)
lightdb@test_oracle-# VALUES ('ABC2', 'Hello', 'world', N'中文', N'こんにちは', 1, 2, 3, 4, 5, 6, 7, 'This is a CLOB', '1');
INSERT 0 1
lightdb@test_oracle=# INSERT INTO testorafce_to_clob (col_char, col_varchar2, col_varchar, col_nchar, col_nvarchar2, col_smallint, col_integer, col_bigint, col_decimal, col_numeric, col_real, col_double, col_clob, col_raw)
lightdb@test_oracle-# VALUES ('ABC3', 'Hello', 'world', N'中文', N'こんにちは', 1, 2, 3, 4, 5, 6, 7, oracle.to_clob('This is a CLOB'), '1AB456789');
INSERT 0 1


lightdb@test_oracle=# SELECT  oracle.to_clob(col_char) AS clob_char,
lightdb@test_oracle-# oracle.to_clob(col_varchar2) AS clob_varchar2,
lightdb@test_oracle-# oracle.to_clob(col_varchar) AS col_varchar,
lightdb@test_oracle-# oracle.to_clob(col_nchar) AS clob_nchar,
lightdb@test_oracle-# oracle.to_clob(col_nvarchar2) AS clob_nvarchar2,
lightdb@test_oracle-# oracle.to_clob(col_clob) AS clob_clob,
lightdb@test_oracle-# oracle.to_clob(col_smallint) AS col_smallint,
lightdb@test_oracle-# oracle.to_clob(col_integer) AS col_integer,
lightdb@test_oracle-# oracle.to_clob(col_bigint) AS col_bigint,
lightdb@test_oracle-# oracle.to_clob(col_decimal) AS col_decimal,
lightdb@test_oracle-# oracle.to_clob(col_numeric) AS col_numeric,
lightdb@test_oracle-# oracle.to_clob(col_real) AS col_real,
lightdb@test_oracle-# oracle.to_clob(col_double) AS col_double,
lightdb@test_oracle-# oracle.to_clob(col_raw) AS clob_nclob
lightdb@test_oracle-# FROM testorafce_to_clob order by col_char asc;
 clob_char  | clob_varchar2 | col_varchar |  clob_nchar  | clob_nvarchar2 |   clob_clob    | col_smallint | col_integer | col_bigint | col_decimal | col_numeric | col_real | col_double | clob_nclob 
------------+---------------+-------------+--------------+----------------+----------------+--------------+-------------+------------+-------------+-------------+----------+------------+------------
 ABC1       | Hello         | world       | 中文         | こんにちは     | This is a CLOB | 1            | 2           | 3          | 4           | 5           | 6        | 7          | AB
 ABC2       | Hello         | world       | 中文         | こんにちは     | This is a CLOB | 1            | 2           | 3          | 4           | 5           | 6        | 7          | 01
 ABC3       | Hello         | world       | 中文         | こんにちは     | This is a CLOB | 1            | 2           | 3          | 4           | 5           | 6        | 7          | 01AB456789
(3 rows)


可以看出,在Oracle兼容模式下LightDB 23.3版本TO_CLOB函数支持了CLOB、字符型以及数值型到CLOB类型的转换。


http://www.niftyadmin.cn/n/4992660.html

相关文章

thinkphp 操作远程oracle遇到的相关坑

坑一:没有内置oracle 解决方法: 1,下载think-oracle 扩展,资源很多,百度即可下载,分别放置于db下的connector 和 builder 文件夹下 2,安装oracle本地客户端,一搜一大把,核…

【ES6】JavaScript中的异步编程:async和await

在JavaScript中,异步编程是一种处理长时间运行的操作的方法,这些操作包括读取文件、网络请求或处理大数据等。在传统的回调函数中,代码按照顺序执行,一旦遇到长时间运行的操作,就需要回调函数来处理结果。这使得代码变…

【Css】Less和Sass的区别:

文章目录 一、定义:【1】Less【2】Sass 二、相同之处:三、区别:【1】实现方式:【2】实现方式:【3】混合(Mixins):【4】解析方式:【5】变量的作用域:【6】比起Less 一、定义: 【1】Less Less 是…

EI、Scopus双检索| 2023年第四届自动化、机械与设计工程国际会议

会议简介 Brief Introduction 2023年第四届自动化、机械与设计工程国际会议(SAMDE 2023) 会议时间:2023年12月8 -10日 召开地点:中国南京 大会官网:www.samde.org 机械设计制造及其自动化学科在国民经济中处于极其重要…

题目有点太简单了,不知道怎么选了

有个公司给了下面一个题目&#xff0c;看了下太简单了&#xff0c;都怕选错了。 后来拿着程序跑了下&#xff0c;就是这个意思嘛。 结论 程序跑出来的结果就是对输入的列表进行倒序排列。 public void testGetPut() throws Exception {List<Integer> numbers List.of(…

在kali环境下安装Beef-Xss靶场搭建

目录 一、更新安装包 二、安装beef-xss 三、启动Beef-Xss工具 1、查看hook.js 2、查看后台登录地址 3、查看用户名和登录密码 4、登录页面 5、点击 Hook me:将配置的页面导入BEEF中 一、更新安装包 ┌──(root㉿kali)-[/home/kali] └─# apt-get update 二、安装bee…

Android 12.0 设置默认屏幕亮度百分比

1.概述 在12.0的系统产品开发中,在一些产品开发中,对于设置默认屏幕亮度和屏幕亮度百分比的功能,在开发中也是常见的功能,在10.0的平台设置可能有一些不同,一般的都是在SettingProvider中设置就可以了 在11.0以后的系统中设置默认屏幕亮度的方法就不同了,接下来具体分析功…

python类的属性和实例的属性有什么区别

在 Python 中&#xff0c;类属性和实例属性是两种不同类型的属性&#xff0c;它们在用途和作用域上有所不同。下面是关于它们的区别的详细解释&#xff1a; 定义位置&#xff1a; 类属性&#xff1a;定义在类的主体中&#xff0c;但在任何类方法之外。实例属性&#xff1a;通常…