I am going on a job interview and have zero experience with MS SQL Server. However I have 1 year with Oracle. Is there such a huge difference between the two? What programming questions can I expect?
Here is a comparison of concepts, terminology and syntax etc. and a comparison of performance / limitations
Also, search SO with tags or keywords like [sql-server], [oracle], "difference" etc. as I'm guessing this topic has been readily addressed, although I didn't find, quickly, such references.
They probably know that you have Oracle experience and you do not have SQL Server experience (unless you lied in your resume). Just answer how you will resolve the problems in Oracle PL/SQL. Do not worry if your answer runs in SQL Server. There are differences but they do not matter in a job interview (except if the position is for a DBA). I know a lot of developers that knew Oracle that got jobs that required SQL Server skills and now they are really good in T-SQL.
Oracle and SQL Server have different extensions of SQL. Oracle has PL/SQL, while SQL Server has Transact-SQL (T-SQL). That means that while SQL (SELECT, INSERT, UPDATE, DELETE) is similar on a basic level, the syntax diverges quickly depending on what you are trying to do.
When I work with T-SQL decision structure/control of flow, I believe it to be less accommodating than PL/SQL - CASE is an expression in T-SQL so it can't be used for control of flow while that's not the case in Oracle. Another irritation I have with T-SQL is that if you want to more than one operation within an IF branch - the entire branch must be contained in a BEGIN END block. Oracle doesn't care, but you have to define the END IF.
Data types are similar, but Oracle doesn't descriminate between integer/decimal types - it's all NUMBER with the option to specify the degree of precision. Date functions in SQL Server are more accommodating.
Both being popular products, it's easy to google for functionality equivalent in one for the other. Doesn't mean it will exist, but someone has probably posted the workaround.
I'm an Oracle and SQL Server DBA who's now spends too much time on SQL Server.
Not to be rude, but for someone who ONLY has 1 year of Oracle experience then I doubt you are totally ingrained into Oracle, but the most obvious differences are:
- The FIRST biggest difference: Transaction control. In Oracle EVERYTHING is a transaction and it is not permanent until you
COMMIT
. In SQL Server, there is (by default) no transaction control. An error half way through a stored procedure WILL NOT ROLLBACK the DDL in previous steps.
Obviously, if you wrap the TSQL DML in BEGIN TRANSACTION and COMMIT then it will roll back but this is rare in SQL Server code I've seen.
- The SECOND biggest difference: MVCC. In SQL Server and Oracle is different. SQL Server will allow dirty reads, and writes can block reads in MS SQL (Again, it's configurable but the default in SQL Server is for performance and not read consistency, unlike Oracle where read consistency is default and unbendable.
Also consider:
When you setup an Oracle server, you tend to have one database with many "users/schemas", and tablespaces that are shared by all your users. SQL Server has separate databases that do not share disk files.
SQL Server uses "logins" to give you access to the SQL Server instance and each database has "users" that map to a login to get individual access to the tables and views etc.
Typically, all the objects in a database are owned by dbo.
TSQL is similar to PL/SQL, but (in my opinion) less powerful. You may need to simplify your SQL to get it to work as well as you'd expect in Oracle.
The SQL Server Management Studio (2008 SP1) is fantastic!
If you like Oracle, all the "getting under the hood" and "explain plan optimisation" then this training and experience will work well for you against guy's who just code straight SQL Server TSQL and expect the server to perform fast by magic.
SQL Server does not have packages. This might start off as a bonus (PL/SQL packages can be a PITA) but eventually you'll start to get a big nest of similarly named stored procedures in the database and you'll wish there was a way you could organise and group then them better.
Final tip, always play to your strengths. Admit that you don't have much SQL Server experience but highlight that you know the principles of how an RDBMS works, how to development a data driven application and how you design in performance from the start, etc.
If you can handle Oracle, you can easily handle SQL Server. Yes the syntax is different, but it is relatively easy to learn the differences. The database concepts of joins and grouping and aggregates, relational design, PK/FK etc are pretty much the same even when the syntax is slightly different. Just highlight your general database knowledge. If they ask specific syntax questions and you don't know the answer for SQl Server, tall how you would do it in Oracle and note that the syntax might be different in SQL server.
One area I have seen where there is a difference is that Oracle performs better using cursors than SQL Server and some people coming from the Oracle world try to do things in cursors when they shouldn't in SQL Server. If you are used to doing row-by-row in Oracle, learn to think in the set-based fashion instead.
You have execution plans and profiler available to help performance tune. Look these up, I'm sure Oracle has similar tools called something different. If you can show you are aware of some of the things you will have to adjust to coming from an ORacle environment, I think that gives you an edge in the interview over someone who hasn't us they aren't happy with the SQL server people whose resumes they got.
From everything I've seen admin is less complex on SQL Server, so again if you can handle Oracle, SQL Server will be easy.
I think just be honest. Dishonesty kills you in a job interview and (no offense), but if you only have 1 year Oracle experience and you didn't lie on your resume then you shouldn't have too much to worry about they won't be expecting you to have "all the answers".
Honestly the biggest difference I've most often encountered is that Oracle is case-sensitive and MS SQL is case-insensitive by default. It leads to more gotchas and bugs than you'd think!
Oracle strengths:
- a better transaction system
- packages
- Cursor For Loops
- anchored declarations (variables declared as table.column%type)
- initial values for variable declarations
- %rowtype variables
- much lower overhead for cursors
- BEFORE triggers
- FOR EACH ROW triggers
- While sequences require either discipline or before each row triggers, they are more flexible than SQL Server identity columns.
SQL Server Strengths:
- Transact-SQL is just one language, so you don't have to worry about what's SQL, what's SQL*PLUS and what's PL/SQL.
- Because T-SQL is just one language, the T-SQL collections actually work decently with SQL. You can join T-SQL table variables to real tables. This tends to mean, while PL/SQL is more powerful for procedural programming, you just don't need to do procedural programming in T-SQL.
- If you perform a select query with no target, the results are automatically returned to the client. For production code, this means you don't need to declare and pass sys_refcursor. For ad-hoc research work, this means you can easily make scripts that perform lookups and display multiple recordsets.
- SQL Server Management Studio is much better than SQL*Plus or SQL Developer. Because it just displays any returned recordsets, data retrieval procedures are very easy to test.
- easier client connectivity setup (nothing as bad as tnsnames)
- less confusion about what drivers to use, apart from JDBC
- Declare a column "Int Identity Not Null Primary Key" and then you can forget about it.
- Every variable name starts with an "@" sigil, which looks terrible, but prevents name collisions between variables and columns.
- The case you declared a table or column with will be remembered, but it's not case sensitive, and you aren't limited to 30 characters.
- Crystal Reports can call SQL Server stored procedures, where you tend to be forced into a view with Oracle.