简体   繁体   English

连接oracle数据库的Perl脚本

[英]Perl script to connect oracle database

I am new to Perl Programming and database connectivity.我是 Perl 编程和数据库连接的新手。 Can anyone please let me know step by step procedure to write Perl Script for Oracle Database connectivity.任何人都可以让我知道为 Oracle 数据库连接编写 Perl 脚本的分步过程。

My Perl Verion is:我的 Perl 版本是:

This is perl 5, version 22, subversion 0 (v5.22.0) built for MSWin32-x64-multi-thread这是为 MSWin32-x64-multi-thread 构建的 perl 5, version 22, subversion 0 (v5.22.0)
Copyright 1987-2015, Larry Wall版权所有 1987-2015,拉里·沃尔
Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Perl 只能在 Artistic License 或 GNU General Public License 的条款下复制,这可以在 Perl 5 源工具包中找到。

I have tried the below:我尝试了以下方法:

my $db = DBI->connect("dbi:Oracle:Local","SYSTEM","SYSTEM") or die print ("could not connect! $DBI::errstr \n");

Since I don't know what is this "dbi:Oracle:Local" I could not able to connect to Database.由于我不知道这个“dbi:Oracle:Local”是什么,我无法连接到数据库。

Can you please let me know what is dbi, Oracle, local.你能告诉我什么是 dbi、Oracle、本地。 if it is Hostname and oracle database name, how can I find the same in my computer.如果是 Hostname 和 oracle 数据库名称,我如何在我的计算机中找到相同的名称。

Do I need to set any ENV variable in Perl?我需要在 Perl 中设置任何 ENV 变量吗? If so, where and what I need to set?如果是这样,我需要在哪里设置和设置什么?

dbi:Oracle lets DBI know which driver to use. dbi:OracleDBI知道要使用哪个驱动程序。 If you're connecting to an Oracle database, you'll never change these.如果您连接到 Oracle 数据库,您将永远不会更改这些。

Local is either an actual database name on the local system, or a name listed in TNSNAMES.ORA . Local要么是本地系统上的实际数据库名称,要么是TNSNAMES.ORA列出的名称。 Substitute the name of the local database you'd like to connect to.替换您要连接的本地数据库的名称。

The next two parameters are username and password.接下来的两个参数是用户名和密码。

If you're connecting remotely, or need to do something more elaborate, consult the docs , or one of the many available guides .如果您是远程连接,或者需要做一些更复杂的事情,请参阅文档或众多可用指南之一

my $db = DBI->connect("dbi:Oracle:Local","SYSTEM","SYSTEM");

"dbi" is a string, “dbi”是一个字符串,
"Oracle" is the driver type, “Oracle”是驱动程序类型,
"local" is the database name, “local”是数据库名称,
First "SYSTEM" is the username and second one is password.第一个“SYSTEM”是用户名,第二个是密码。

use DBI;
my $dbh = DBI->connect( "dbi:Oracle:databaseName", 'username', 'passwd' ) or die($DBI::errstr, "\n");

First read the basic concept of Simple Database access using Perl DBI and SQL .首先阅读使用 Perl DBI 和 SQL 访问简单数据库的基本概念。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM