Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching

Oracle Engineered System


当前位置: 首页 » 技术文章 » Cloud

Oracle Database Multilingual Engine(MLE)

Oracle Database Multilingual Engine (MLE)是Oracle Database 12c的一个实验特性。MLE让开发人员能够用自己选择的现代编程语言和开发环境高效地处理数据库中驻留的数据。在第一版中,为用户提供了一种运行用JavaScript或TypeScript 编写的存储过程和用户定义的函数的方法。他们正在构建一个执行引擎,但是这个引擎能够运行用不同语言编写的程序,以包括Ruby,Python,PL/SQL,C,R等其他语言。这个新引擎在某些处理过程中比PL/SQL运行速度更快,而且看起来与SQL引擎的上下文切换非常高效。

Oracle Database MLE以VirtualBox映像的形式提供。该映像包含Oracle Database MLE、文档和教程。还包括一个部署工具 (dbjs),可用于将JavaScript 模块部署到数据库中。数据库可以将这些模块导出的函数作为存储过程或用户定义的函数进行调用。虚拟机下载地址
http://www.oracle.com/technetwork/database/multilingual-engine/downloads/index.html

[oracle@dbml ~]$ sqlplus / as sysdba
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0_MLE - 64bit Beta
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select name from v$database;
NAME
---------
DBML
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0_MLE - 64bit Beta
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[oracle@dbml ~]$

部署工具dbjs

[oracle@dbml ~]$ which dbjs
/usr/local/bin/dbjs
[oracle@dbml ~]$ ls -l /usr/local/bin/dbjs
lrwxrwxrwx. 1 root root 34 Sep 29  2017 /usr/local/bin/dbjs -> ../lib/node_modules/dbjs/bin/db.js
[oracle@dbml ~]$ ls -l /usr/local/lib/node_modules/dbjs/bin/db.js
-rwxrwxrwx. 1 root root 7315 Sep 29  2017 /usr/local/lib/node_modules/dbjs/bin/db.js
[oracle@dbml ~]$ 
Oracle Database MLE要求所有JavaScript扩展作为JavaScript模块实现,这是JavaScript开发人员的通常做法。Oracle Database MLE支持以UMD 模块形式编写的模块。这是很常见的模块编写模式,可以通过各种工具(如 browserify)生成。但是,编写可以由Oracle Database MLE加载的模块的最简单的方法是使用Common-JS,并将可从Oracle 数据库调用的函数指定为“module.exports”的属性,下面是示例:
1.编写JavaScript,并保存为helloworld.js
module.exports.helloworld = function () { return "Hello World"; }
2.编写TypeScript声明文件,并保存为helloworld.d.ts
export function helloworld() : string;
3.部署到数据库
dbjs deploy helloworld.js -u scott -p tiger -c localhost:1521/DBML
[oracle@dbml ~]$ dbjs deploy -vv helloworld.js -u scott -p tiger -c localhost:1521/DBML
deploy: command called  /home/oracle/helloworld.js oracle
Oracle backend: starting transpiler
helloworld: processed function
Oracle backend: opening connection to database
loadModule: called with helloworld.js
BEGIN
EXECUTE IMMEDIATE 'CREATE PACKAGE HELLOWORLD AS
FUNCTION HELLOWORLD RETURN VARCHAR2 AS LANGUAGE JS LIBRARY "helloworld.js" NAME "helloworld" ;
END HELLOWORLD;';
END;
: generated PLSQL
+ helloworld.js
└─┬ helloworld
  └── SCALAR FUNCTION HELLOWORLD.HELLOWORLD RETURN VARCHAR2
[oracle@dbml ~]$ 
4.从SQL调用UDF
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0_MLE - 64bit Beta
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> select helloworld() from dual;

HELLOWORLD()
--------------------------------------------------------------------------------
Hello World
SQL>

下面这篇文章测试更有说服力

http://blog.dbi-services.com/oracle-database-multilingual-engine-mle/


Reference
http://www.oracle.com/technetwork/database/multilingual-engine/overview/index.html
http://www.oracle.com/technetwork/cn/database/multilingual-engine/overview/index.html
http://www.oracle.com/technetwork/cn/database/multilingual-engine/documentation/index.html
http://pages.pacificcoast.net/~cazelais/euclid.html
http://blog.dbi-services.com/oracle-database-multilingual-engine-mle/

https://oracle.github.io/oracle-db-mle/releases/0.2.7/

https://oracle.github.io/oracle-db-mle/vbox/


关键词:mle cloud oracle 

相关文章

基于PDB的Active Data Guard(Oracle 21.7+)
在Oracle数据库中使用REST
OGG from MySQL to Oracle
Oracle数据库容灾之两地三中心实践
低代码开发用Oracle Apex,看这篇就够了
Oracle Database 20c之SQL宏
Java beginner for Oracle DBA
Oracle Database 20c之区块链表
Oracle Database 20c的一些微妙变化
关于Oracle的Sequence,你需要知道的
Oracle数据库优化方面资料
Oracle Database 19c在优化方面有哪些新特性
Top