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 

相关文章

Exadata最权威最完整的学习资料
Oracle数据库C函数解析
MySQL Cookbook for Oracle DBA
Full Transportable Export/Import(fxtts)
Oracle自治数据仓库云
expdp on physical standby
Oracle Database 12c之后DataGuard环境中的PDB操作
How to generate AWR for Standby Databases
Oracle DataGuard in 18c & 19c
通过gDBClone快速的构建开发测试环境
Oracle Database Express Edition 18c发布了
在18c中通过ASM Flex DiskGroup克隆PDB
Top
Cell186-9589-1286
QQ 375349564
E-mail ohsdba@qq.com