Oracle and SQL Server
24 questions in 7 subtopics.
Oracle sequences, ROWNUM and FETCH FIRST
How do Oracle sequences work with JPA's@GeneratedValue(strategy = SEQUENCE) and allocationSize? What happens if the sequence INCREMENT BY does not match allocationSize?A developer writes SELECT * FROM orders WHERE ROWNUM <= 10 ORDER BY created_at DESC in Oracle to get the 10 newest orders, and the results are wrong. Explain why and give two correct versions.An Oracle RAC system shows heavy 'enq: SQ - contention' and index block contention on the primary key of a hot orders table during peak inserts. How would you address it?Your company is migrating 60 Oracle schemas to PostgreSQL. Applications rely on Oracle sequences, ROWNUM pagination, and SYSDATE in SQL. How do you plan the SQL and id generation side of the migration?Oracle undo and read consistency
How does Oracle give a query a consistent view of data while other transactions update the same rows, without read locks?A long-running Java report on Oracle fails after 2 hours with ORA-01555: snapshot too old. What does it mean, and how do you fix it?You are moving a workload from Oracle to PostgreSQL. Both use MVCC, but differently. What operational differences in versioning should your teams expect?Oracle's flashback features (flashback query, flashback table, flashback database) have been used by your DBAs for years to recover from bad deploys. As you consider leaving Oracle, how do you assess what this capability is worth and what replaces it?PL/SQL basics
Write a PL/SQL procedure that transfers an amount between two accounts and raises an error if the balance is too low, and show how you would call it from Java with JDBC.A Java service calls a PL/SQL function row by row in a loop for 500,000 records, and the job takes hours. What are the costs involved and how do you speed it up?A core system holds 400,000 lines of business logic in PL/SQL packages, and the company wants to move to Java services and possibly off Oracle. How do you plan this?SQL Server snapshot isolation
What is the difference between SQL Server's READ COMMITTED with locking,READ_COMMITTED_SNAPSHOT (RCSI), and SNAPSHOT isolation?A Java application on SQL Server suffers frequent deadlocks between a reporting SELECT and order updates. The DBA proposes enabling READ_COMMITTED_SNAPSHOT. What do you check before turning it on?Teams use NOLOCK hints widely in SQL Server queries to avoid blocking. What risks does that carry, and what platform-level policy would you set instead?SQL Server clustered indexes
What is a clustered index in SQL Server, how does it differ from a nonclustered index, and why does the choice of clustering key matter?A table clustered on a random UUID primary key (NEWID()) shows heavy page splits, fragmentation above 90 percent and slow inserts. What options do you have, including from a Java application?You are designing tables for a system that must run on both SQL Server and PostgreSQL. PostgreSQL tables are heaps, SQL Server tables are usually clustered. How does this difference affect schema and query design?JDBC drivers and dialect differences
Name the JDBC driver coordinates and typical URL formats for Oracle and SQL Server, and two behaviour differences a Java developer notices compared with PostgreSQL.A query on SQL Server filters on a VARCHAR(20) indexed column with a JDBCPreparedStatement parameter. It does an index scan instead of a seek and takes 2 seconds. The same query in SSMS with a literal is fast. Why?Your product must support PostgreSQL, Oracle and SQL Server for on-premise customers. How do you structure data access, migrations and testing so dialect differences do not cripple the team?Supporting three database engines has slowed your product for years. Sales says enterprise customers demand Oracle and SQL Server. How do you decide whether to drop support for one or more engines?Licensing and cost considerations
What licensing factors drive the cost of Oracle Database and SQL Server deployments, and how do they affect architecture choices such as virtualisation and read replicas?An internal audit found that a team enabled an Oracle feature (Diagnostics Pack AWR reports and Partitioning) without licences. How do you respond and prevent recurrence?Your company spends 9 million dollars a year on commercial database licences. The CFO asks whether to move to PostgreSQL. How do you build the business case and the risk assessment?No question matches these choices.