views:

308

answers:

5

I'm seeing a lot of job posts that specifically mention Oracle and PL/SQL. What's unique about programming for this database?

How different is it from programming for any other database, especially from Java? Isn't it the same normal SQL? Can't one just use JDBC?

I've worked in the past with MySQL, DB2, and MSSQL, but haven't seen Oracle since college and back then it seemed fairly standard.

+6  A: 

PL/SQL is all the extensions that Oracle has added to SQL to do stored procedures. SQL itself doesn't really define many traditional programming constructs, and mostly deals with how to do set based operations. MS SQL Server has TSQL. MySQL, PostGreSQL and the others all have their own library of functions that can be called to do certain operations. The standard SELECT, JOIN, UPDATE, INSERT, UNION and other things are all the same. It's the stored procedure programming that's different between the database vendors.

I haven't used Oracle much at all, but it seems to me like people who use Oracle seem to put a whole lot more logic into the database then is generally done by people using other database engines.

Personally, the fact that this code isn't portable between database vendors is one of the reasons I try to put as little logic as possible in the database layer, and try to stick to basic SQL that will work across all databases with little or no modification

Kibbee
"...it seems to me like people who use Oracle seem to put a whole lot more logic into the database then is generally done by people using other database engines." That's probably because Oracle has a much better programming language than the rest.
Tony Andrews
As for making your database layer portable, this only really matters if you are selling a product that really NEEDS to be portable. Making it portable unnecessarily would be a gross waste of the money spent buying a sophisticated DBMS like Oracle.
Tony Andrews
It is true that you shouldn't waste time making it portable, but I believe that if there are two options for implementing a specific feature, and one is portable and the other is not, ...
Kibbee
... and the development time and efficiency of the two methods is the same, I would choose the portable method over the non-portable version. Whereas many don't even know what is portable, or just go to the non-portable method by default.
Kibbee
"The standard SELECT, JOIN, UPDATE, INSERT, UNION and other things are all the same." - not completely. There are sometimes subtle differences, and also features which are in the ANSI standard but not supported by all DBs.
Lucero
+2  A: 

Every database has its own ins and outs, they support different features, use different transactional models etc. If you want to be as efficient as possible, you have to know your tools. Even hiding behind an ORM like Hibernate won't hide the underlying database for too long.

From a Java viewpoint, no, it's not different from other databases if you access it via JDBC. However, Oracle's SQL implementation has a lot of features that other databases don't have; as I already mentioned, it helps to know what you can use.

andri
A: 

I think that administering Oracle is a different kettle of fish from MySQL or SQL Server. I think the reason for the ads is that it's become a unique specialty.

From a JDBC point of view, it's no different from any other database. If you stay away from vendor specific extensions your code will be portable; if you don't, it won't be.

duffymo
Administering a database is a much different thing that programming within a database ;)
HardCode
Indeed. But the first sentence said that he noticed a lot of jobs mentioning Oracle and PL/SQL, but I thought the leap to "programming" instead of "admin" was more from the questioner than the ad.
duffymo
+2  A: 

Take a look at this question:

http://stackoverflow.com/questions/702500/sql-query-to-collapse-duplicate-values-by-date-range

Two of the answers rely on Oracle extensions to get the answer; my answer does it in ANSI SQL,

The Oracle extensions address the nasty corners of SQL (that is, the stuff that isn't pure set handling, the stuff SQl was never designed to handle): dealing with the first something (first row, first row in group), the last something, ranks of things (give every row a number; give every row a rank that increments when department changes, give every row a rank that changes when both department and salary change), pivot a table, etc.

Almost all of these things can be done in ANSI SQL, with subqueries or group bys or aggregate functions or user defined functions, but these things tend to be expensive. By making them built-ins, the PL-SQL are probably faster.

(Again, look at my answer, to the question linked above; I do a couple subqueries with aggregate functions. The other answers do subqueries too, but avoid the grop bys by using the PL-SQL functions. Honestly, I think my way make for clearer code, but an Oracle DBA might disagree.)

tpdi
+2  A: 

If you truly want to leverage your database and not just use it as a bit bucket, then you need to understand your database. While the major ( MS-SQL, DB2, Oracle, Postgres, MySql ) all support SQL, they all have their own way of doing different things, They all have their own way of optimizing queries, picking execution plans, indexing options for tables, structures for tables, and languages which run in the database.

For example, in MS-SQL its common (I believe?) to create a temporary table on the fly and use it within your transaction, dropping the table at the end. You would never do this in Oracle, in Oracle the DBA creates the temporary table once, with the contents being visible only to the transaction which inserted it.

I guess this question is a bit like asking "Is PHP really that different from Ruby", They are both interpreted,dynamic languages, often used to solve the same problems, but your approach could be very different between the two.

For just basic CRUD applications via jdbc, then Oracle is going to be very similar to any other modern RDBMS, however you should be aware of its locking and transaction models. How you approach a function to update 500,000 rows effeciently in the database might be very different from any other database though.

Matthew Watson
No reason to get this aggressive with it.I've been using databases in the past 10 years for research systems where they indeed served as bit buckets, primariy. I was wondering about Pl/SQL since I don't see ads for DB2 experts and such.
Uri
sorry, I think you are reading it wrong, i'm not being aggressive at all, use your database for whatever you want, no point in buying oracle if you aren't going to leverage it though
Matthew Watson
@Uri, I don't see any aggressiveness in Matthew's words.
tuinstoel