Wednesday, April 23, 2008

EDB Tip #4: Database Links in EDB


LewisC's An Expert's Guide To Oracle Technology


This tip relates to the latest version of EnterpriseDB's Advanced Server (AS) product. This is the commercially licensed database that provides Oracle compatibility. I have spoken quite a bit about what that compatibility entails but the gist of it is that the compatibility is code compatibility. The latest version of AS offers quite a few new features that I will be writing about over time. Today I am writing about the Oracle compatible db links.


To understand database links in Oracle, read my entry here on ittoolbox, Database Links: A Definition in Plain English. That entry will give you a good overview of what a link is and what Oracle does with links. This is a hugely useful feature. Pulling data from remote databases can be incredibly important to many applications.


AS provides DDL syntax that is very close to Oracle syntax and DML syntax exactly like Oracle syntax. In addition, you can choose to create links from AS to Oracle or links from AS to other AS instances or even to Postgres instances.


The AS syntax to create a link:



CREATE [ PUBLIC ] DATABASE LINK name
CONNECT TO username IDENTIFIED BY 'password'
USING { libpq 'host=hostname port=portnum dbname=database' |
[ oci ] '//hostname[:portnum]/database' }

Let me break that up just a bit by comparing it to Oracle's syntax:



CREATE [ SHARED ] [ PUBLIC ] DATABASE LINK dblink
[ CONNECT TO
{ CURRENT_USER
| user IDENTIFIED BY password
[ dblink_authentication ]
}
| dblink_authentication
]
[ USING 'connect_string' ] ;

Oracle has an additional keyword, SHARED. This keyword allows multiple users to share a database link. AS does not currently support this syntax.


In both instances, you can choose to create a public or a private link. A public link can be accessed by anyone in a database, a private link can only be accessed by the creator.


dblink is the name of the link. A database link in AS may be any valid name.


In both cases, you define who to connect as and the password for that user. Oracle offers an additional option to connect as CURRENT_USER. AS does not offer that keyword at this time.


In Oracle's syntax, the dblink_authentication is tied to the SHARED database link type.


Both databases have the USING keyword but this is where AS differs most from Oracle.


In AS, when you use USING, you chose to connect to an Oracle database (OCI) or a postgres database (LIBPQ), which would include an AS database. This keyword, OCI or LIBPQ, tells AS which library to use to connect to the remote database. The syntax is mostly the same for both types of database: server, port and database name.


Some examples (I will use EDB*Plus to run the examples):


If I wanted to create a private database link from my local AS server to an AS database (in this case, the same database), I would use this syntax:


CREATE DATABASE LINK aLocalAsDb
CONNECT TO enterprisedb IDENTIFIED BY edb
USING libpq 'host=localhost port=5444 dbname=edb'





Connected to EnterpriseDB 8.3.0.12 (localhost:5444/edb) AS enterprisedb

EDB*Plus: Release 8.3 (Build 14)
Copyright (c) 2008, EnterpriseDB Corporation. All rights reserved.

SQL> drop database link alocalasdb;

Database Link dropped.

SQL> CREATE DATABASE LINK aLocalAsDb
2 CONNECT TO enterprisedb IDENTIFIED BY edb
3 USING libpq 'host=localhost port=5444 dbname=edb'
4 /

Database Link created.

SQL> select 123 from dual@alocalasdb;

?COLUMN?
-----------
123

SQL>


Creating and using a link to Oracle is very similar. I have an Oracle XE database. I will create a public link that connects to the HR user. I would use this syntax:



EDB*Plus: Release 8.3 (Build 14)
Copyright (c) 2008, EnterpriseDB Corporation. All rights reserved.

SQL> conn enterprisedb/edb
Connected to EnterpriseDB 8.3.0.12 (localhost:5444/edb) AS enterprisedb

SQL> create public database link oraxe
2 connect to hr identified by hr
3 using oci '//localhost:1521/xe';

Database Link created.

SQL> select 123 from dual@oraxe;

?COLUMN?
-----------
123

SQL> select count(*) from employees@oraxe;

COUNT
--------------------
107

SQL>

And that's just about it. At this time, you cannot use a database link to call a remote procedure. That is planned for the future.


Also, if you connect to an 11g database, you may need to quote your password if you use a mixed case password in Oracle. 11g allows users to have mixed case passwords.


Because AS is using OCI to connect to the Oracle database, you must have an Oracle client installed and correctly configured on the AS server to create a database link to Oracle. You may use the instant client or the full client. Your ORACLE_HOME must also be correctly set. It can also be set in an AS configuration file.


Take care,


LewisC






Technorati : , ,

Combined Forums for Postgres and EnterpriseDB Issues

In the past, your basic support for postgres has been mail groups. I've never been a big fan of mail groups. You have to subscribe to the group and usually you get tons of stuff you don't really want. Worst of all, you either have to sort through it or filter it to a folder. I never seem to be able to keep up with the stuff I am interested in due to the clutter.

EnterpriseDB has had forums for a while but recently combined the postgres and advanced server forums into a single location. GridSQL also has it's own forum. You can ask pretty much any question you might have. The forums are monitored by EnterpriseDB employees and there are also some very knowledgeable users out there.

LewisC



Wednesday, March 26, 2008

EnterpriseDB Open Sources GridSQL

I wrote about GridSQL and EnterpriseDB a while back. EnterpriseDB bought GridSQL (from Mason who now works at EnterpriseDB) and has been working to improve it. Yesterday, they announced that they are open sourcing it.

GridSQL is really for data warehousing but can be applied to some OLTP/reporting combination databases. What it does is take a query and spread it out to run in parallel against a set of cheap PCs. There is a controller machine, called a coordinator, that keeps track of what is running and where.

Because there is a central point of failure (the coordinator), it is not a high availability solution. But, also because of the coordinator, you can hot swap, add or remove nodes while users are accessing the data. Very cool technology.

LewisC






Friday, March 7, 2008

A New EnterpriseDB Webinar

I'm doing a "Best Practices on Database Migration" webinar at ITToolbox.com March 12.

I'll talk about ways to make your life easier when doing database migrations.

LewisC



Monday, February 11, 2008

Open Source Data Integrator Apatar Announces Partnership with EnterpriseDB

Apatar is a provider of open source software tools for the data integration market. Apatar provides data integration to the companies by offering provides support, training, and consulting services for its integration software solutions.

Apatar provides connectivity to EnterpriseDB, Oracle, MS SQL, MySQL, Sybase, DB2, MS Access, PostgreSQL, XML, InstantDB, Paradox, BorlandJDataStore, Csv, MS Excel, Qed, HSQL, Compiere ERP, SalesForce.Com, SugarCRM, Goldmine, any JDBC data sources and more.

The free Community Edition is available for download and provides plenty of functionality out of the box. There is a also an Enterprise Edition that provides some additional features. You can compare features in the feature matrix.

"We are pleased to support EnterpriseDB's world-class database solutions as part of our integration practice," said Renat Khasanshyn, founder and CEO of Apatar, Inc. "In today's enterprises, most data integration projects never get built. The ROI (Return on Investment) on the small projects is simply too low to justify bringing in expensive middleware. Apatar entered this market as an open source vendor bringing the ease of drag-and-drop data integration, including with EnterpriseDB databases, to the companies that previously found proprietary data integration, ETL, and EAI software tools expensive and difficult to implement."



Tuesday, February 5, 2008

EnterpriseDB CEO Named One of the “Top Leaders in Open Source Business”

EnterpriseDB's CEO, Andy Astor, was named one of 13 “Top Leaders in Open Source Business” by LinuxWorld Magazine. EnterpriseDB was also recently named one of the “Top 20 Companies to Watch in 2008" by Linux Magazine.

This is good news for open source and for people looking to save money on database license fees.

EnterpriseDB sells the open source based Oracle compatible EnterpriseDB Advanced Server as well as a packaged Postgres implementation. EnterpriseDB also offers consulting and training.




Tuesday, January 22, 2008

EnterpriseDB: The Definitive Reference for less than $25 USD

If you've thought about buying the book, EnterpriseDB: The Definitive Reference, you should check out A1Books.com. As of right now, 1/22/08, it's going for $24.80 USD (Brand New).

Shipping would depend on your location.

LewisC




Software Blogs - Blog Catalog Blog Directory Software blogs Top Blog Sites Blog Flux Directory Lewis Cunningham