|
Sander Rossel wrote: Do people here actually like the Oracle database? Yep
Sander Rossel wrote: Especially when compared to SQL Server. Well, both are good and have their place. One benefit with Oracle is to be able to run it on different platforms. On the other hand SQL Server admin tools are more intuitive and so on. I'd say that the differences become meaningful in environments that have special requirements.
Sander Rossel wrote: It seems everything I did so easily in SQL Server seems to be difficult or even impossible in Oracle. Any examples?
|
|
|
|
|
Mika Wendelius wrote: One benefit with Oracle is to be able to run it on different platforms. Yes, that's one I heard and a very plausible one at that!
Good thing we run it on Windows servers
Mika Wendelius wrote: Any examples? Table variables, simply declaring some variables and using them (in all manner of ways).
For example, I simply wanted to something like the following:
DECLARE @Names TABLE (Name VARCHAR(100))
INSERT INTO @Names
SELECT Name
FROM Person.Person
SELECT @Names
SELECT Column
FROM Table
WHERE Name IN @Names
DECLARE @SomeText VARCHAR(100)
SET @SomeText = "Not doable in Oracle"
SELECT @SomeText I think the first thing with the table variable just isn't possible. My coworker, who worked with Oracle for about 30 years now, looked at me in disbelief and asked why I wanted to do such a thing anyway
The second, declaring a variable, assigning it a value and simply selecting it (FROM DUAL???) is just so awkward.
Having multiple result sets in one procedure/session isn't possible.
For example, from my software I want to insert an order, its details and do some auditing/logging and check if everything is in the database as expected.
SELECT * FROM SalesOrder
SELECT * FROM SalesOrderDetail
SELECT * FROM AuditLog I have to execute the statements one by one and check the results, no way to do it all at once and get the results next to each other.
Please, I beg of you, prove me wrong! It would make my life so much easier
Maybe I'm in a "SQL Server state of mind" and Oracle just is another paradigm? Like OOP vs. Functional? And I'm simply missing it?
|
|
|
|
|
Hopefully people don't mind me posting a few technical stuff...
Sander Rossel wrote: I think the first thing with the table variable just isn't possible. Why? You can define a type and you can define a table for a type: PL/SQL Tables and User-Defined Records[^] Sander Rossel wrote: The second, declaring a variable, assigning it a value and simply selecting it (FROM DUAL???) is just so awkward Why not use a simple assignment
X:=5; Sander Rossel wrote: Having multiple result sets in one procedure/session isn't possible. Yes it is, and you can use REF cursors: Optimize Result Set Retrieval Using ODP.NET and Ref Cursors[^]
If these cause you headache, we can take the discussion outside, for example to Q&A. Lounge is not appropriate for these
|
|
|
|
|
|
This works ...
DECLARE
x NUMBER;
y NUMBER;
BEGIN
x := 5;
SELECT x into y FROM DUAL;
dbms_output.put_line(y);
END;
The environment that nurtures creative programmers kills management and marketing types - and vice versa. - Orson Scott Card
|
|
|
|
|
Joe Simes wrote: dbms_output.put_line(y); I know, but having many fields and rows (or a few with variable length) requires a gigantic put_line which will become unreadable. I really want my result to be in a table
|
|
|
|
|
DECLARE
CURSOR c is SELECT * FROM DUAL;
r dual%ROWTYPE;
d dual.dummy%TYPE;
BEGIN
open c;
fetch c into r;
d := r.dummy;
dbms_output.put_line(d);
END;
The environment that nurtures creative programmers kills management and marketing types - and vice versa. - Orson Scott Card
|
|
|
|
|
Yes I believe the state of mind is a powerful thing to overcome.
As to your questions, they have already been addressed by Mika.
Oracle is undoubtedly a bit quirkier than SQL Server, but it's more consistent in my opinion, it's a little bit like going from VB to C#.
|
|
|
|
|
Jörgen Andersson wrote: it's a little bit like going from VB to C#.
Thank you so much! Now I have to wipe away the stains of tea from my monitor...
|
|
|
|
|
Glad to be of service.
|
|
|
|
|
|
Teaching old dogs new tricks.
Well I rarely use implicit joins, and do you know why, you can't decide the order of the joins (outer) if they're implicit. Better get used to a consistent way of doing things.
One reason that the old people use implicit joins is that on Oracle the optimizer was for a long time better at handling implicit joins.
But sometimes when I don't get the performance I expect I try implicit joins instead of ANSI joins.
It's all about the order of execution. (I'm having an article about that on the way)
|
|
|
|
|
Jörgen Andersson wrote: One reason that the old people use implicit joins is that on Oracle the optimizer was for a long time better at handling implicit joins. I actually read that today
The reason I don't like it is because it really obscures your where clause and invites bugs because you forgot to join two tables in the where clause (actually happened today, that's why I read about it).
It shouldn't matter for your performance though, so I was pretty surprised it DOES matter for performance in Oracle (and not in the way that you want either).
|
|
|
|
|
The best part of Oracle is that I rarely have to use it anymore.
I even hate the Gigs of pollution you had to install just to talk damned thing.
So now when I have to talk to it from VS I just add one file to my project (Oracle.ManagedDataAccess.dll) and then have all the access I need.
The bare minimum
|
|
|
|
|
RossMW wrote: The bare minimum Still too much
|
|
|
|
|
Yep.
|
|
|
|
|
It''s interesting to read the comments in this thread.
Having worked for many years on Oracle, but now having changed company to work with SQL server, I have quite different experience.
SQL Server is a much less mature product. It really feels like going fifteen years back in time.
Programming in T-Sql feels like using prehistoric VB, the code is totally littered with stupid prefixes like @ and #. And it lacks consistency.
The worst part is probably lock handling, on Oracle I never needed to think about it, period.
No flashback queries. On Oracle you can do a SELECT AS OF TIMESTAMP . Even from dropped tables.
Always on failover is a really poor substitute for RAC. Half the point with clustering is gone if you can only use one node at a time.
Composite indexes are only having statistics on the first column, reducing the efficiency of the optimizer considerably.
No pipelined functions, at all.
I can keep on going for long.
On the other hand, SSIS is just brilliant.
|
|
|
|
|
|
You can think of pipelined functions in the same way as yield return in C#.
Flashback really is the best thing since sliced bread. It's a bit of a performance drain, but still faster than SQL Server though.
Ever wondered why you get the query time in seconds in SSMS and in ms from Oracle?
Sander Rossel wrote: Unfortunately, due to awful tooling from Oracle
Well, I certainly give you that one, SSIS is simply awesome despite some quirks.
Sander Rossel wrote: you're actual DBA's
I'm not, I'm both a backend developer and database developer. No admin in my title to be found.
Sander Rossel wrote: but that's not very interesting to the average developer?
That's maybe where the problem is. People don't understand what's going on in the databases, and SQL-Server is much better integrated with Visual Studio so it's really quite hidden from people.
I once saw someone here comment that the biggest problem with Access is that it makes it to easy for people that don't know what they are doing to create a database. Well that statement really holds a bit of truth for SQL Server as well.
That's also why we're seeing these reactionist NOSQL databases which is really bringing us back to the sixties.
BTW, one of the big differences between PL-SQL and T-SQL is that there is a lot of implicit stuff going on in T-SQL. In PL-SQL you have to define everything. And that's probably why you thought you can only have one return set from PL-SQL.
|
|
|
|
|
Jörgen Andersson wrote: Ever wondered why you get the query time in seconds in SSMS and in ms from Oracle? I never got a timeout in Oracle and plenty in SQL Server...
I SHOULD mention that I haven't worked with Oracle like I have with SQL Server (few months development in Oracle vs. years of development and production in SQL Server).
Jörgen Andersson wrote: I'm not, I'm both a backend developer and database developer. No admin in my title to be found. Still, your profile says "Database developer" rather than "Software developer"
Jörgen Andersson wrote: People don't understand what's going on in the databases Very true, although my experience is that people don't know what's going on inside C# (or any technology for that matter) as well.
Most people are missing theoretical knowledge because that's just not interesting, we're practical and need results
Just recently a coworker complained that a SELECT TOP 10 * FROM SomeView was very slow so we should move the select statement from the view to an SP and pass in the TOP 10 as parameter to that SP. Yes, because that's certainly going to make it a lot faster... (his idea was actually that the entire view was selected (and the view didn't have a top 10) and that the top 10 was applied after that).
Jörgen Andersson wrote: That's also why we're seeing these reactionist NOSQL databases which is really bringing us back to the sixties. I have to disagree there! I'm no NoSQL expert, but I really think NoSQL databases solve actual problems and can be successfully leveraged to create highly performant systems where traditional relational databases would fail miserably. Of course you still have to know what you're actually doing.
Jörgen Andersson wrote: that's probably why you thought you can only have one return set from PL-SQL Nope, I actually want to see exactly this[^] in SQL Developer, but it's impossible
|
|
|
|
|
Sander Rossel wrote: I never got a timeout in Oracle and plenty in SQL Server.
Probably a setting though.
Sander Rossel wrote: his idea was actually that the entire view was selected (and the view didn't have a top 10) and that the top 10 was applied after that)
He might be right you know, check the plan.
That's also why you should avoid views with joins as the plague! I never use views for anything but restricting access or prefiltering tables.
modified 18-Oct-16 17:54pm.
|
|
|
|
|
Jörgen Andersson wrote: He might be right you know, check the plan. HE MIGHT be right that an SP would be faster, but not because the TOP 10 is applied after selecting everything from a view
I did check the plan and it was really pretty hopeless.
Basically the view was this:
SELECT SomeFields
FROM BigTable
WHERE ...
UNION
SELECT SomeOtherFields
FROM BigTable
WHERE ...
Now to get that to work we probably DO need an SP because to get the top 10 the selects on both sides of the union needed to be completely evaluated, then sorted, and then top 10'd.
I wouldn't really know how to optimize that in a view. It's probably faster to take both top 10's, union and sort those and take another top 10
|
|
|
|
|
Sander Rossel wrote: , but not because the TOP 10 is applied after selecting everything from a view
Sander Rossel wrote: because to get the top 10 the selects on both sides of the union needed to be completely evaluated, then sorted, and then top 10'd.
That's a bit contradicting you know.
Sander Rossel wrote: It's probably faster to take both top 10's, union and sort those and take another top 10
That's it.
And that's exactly why I avoid views. You're forgetting what's happening underneath.
|
|
|
|
|
Jörgen Andersson wrote: That's a bit contradicting you know. You can't say "a TOP X is applied after selecting everything from a view" for views in general.
It's true for this particular view, but you only know that after looking at the view. Besides, the WHERE clause was still applied even before "selecting everything"
|
|
|
|
|
It doesn't have anything to do with the view, it's because the TOP is the last thing to happen in the logical order of execution.
|
|
|
|