Quick Revision

GK One-Line Question & Answer

15541+ short questions with short answers, covering every category and sub-category on the site — no long articles to scroll through. Good for a fast recap before an exam, or a few minutes of daily practice.

DBMS → Database Security 1

What is data privacy by design in the context of database systems?
An approach where privacy protections are built into database systems from the beginning (by design) rather than added later (by afterthought); includes: minimizing data collection (only store what is needed) purpose limitation (data used only for stated purpose) data retention policies (auto-delete after retention period) privacy-preserving queries (differential privacy k-anonymity) and privacy impact assessments before schema changes
click to copy

DBMS → PL/SQL 28

What is the difference between a PL/SQL stored procedure and a stored function?
Stored procedure: a named block that executes logic and may return values via OUT/IN OUT parameters called with EXECUTE/CALL cannot be used in SQL expressions. Stored function: MUST return a single value via RETURN can be called from within SQL expressions (SELECT WHERE) and is side-effect restricted in SQL contexts
click to copy
What is PRAGMA EXCEPTION_INIT in PL/SQL?
A compiler directive that associates a user-defined exception name with an Oracle error number allowing you to catch specific Oracle errors by name rather than using WHEN OTHERS and checking SQLCODE
click to copy
What is the difference between implicit cursor and explicit cursor in PL/SQL?
Implicit cursor: automatically created by PL/SQL for single-row SELECT INTO or DML statements (attributes: SQL%ROWCOUNT SQL%FOUND SQL%NOTFOUND SQL%ISOPEN). Explicit cursor: developer-declared named cursor for multi-row queries with full control over OPEN FETCH CLOSE lifecycle
click to copy
What is BULK COLLECT and FORALL in PL/SQL and how do they improve performance?
BULK COLLECT: fetches multiple rows from a cursor into a collection in a single context switch. FORALL: executes a DML statement for all elements of a collection in a single context switch. Both minimize expensive PL/SQL-to-SQL engine context switches
click to copy
What is a REF CURSOR in PL/SQL and what is its advantage over static cursors?
A pointer to a query result set that can be passed as a parameter between programs or returned from a function; advantage: the query can be determined at runtime (dynamic) and the cursor can be returned to a calling program (Java/Python) as a result set
click to copy
What is EXECUTE IMMEDIATE in PL/SQL and when is it used?
Used to execute dynamic SQL strings built and executed at runtime allowing PL/SQL to execute DDL DML with runtime-determined table names/conditions or PL/SQL anonymous blocks not known at compile time
click to copy
What are PL/SQL collections (Associative Arrays Nested Tables VARRAYs) and how do they differ?
Associative Array (INDEX BY): unbounded sparse indexed by PLS_INTEGER or VARCHAR2 exists only in PL/SQL memory. Nested Table: initially dense can have gaps (DELETE) can be stored in database column. VARRAY: fixed maximum size always dense (no gaps) ordered can be stored in database column
click to copy
What is AUTONOMOUS TRANSACTION pragma in PL/SQL?
A pragma that makes a PL/SQL block run in its own independent transaction separate from the calling transaction - used for: writing audit/log records that persist even if the main transaction rolls back
click to copy
What is the difference between statement-level and row-level triggers in PL/SQL?
Statement-level trigger: fires ONCE for the entire DML statement regardless of how many rows are affected (cannot access :NEW/:OLD). Row-level trigger (FOR EACH ROW): fires ONCE for each affected row has access to :NEW (new values) and :OLD (old values) for validation and auditing
click to copy
What is mutating table error in PL/SQL?
An error (ORA-04091) that occurs when a row-level trigger tries to read from or write to the table that fired the trigger - the table is in an inconsistent state during the DML so Oracle prevents the trigger from querying it to avoid reading partial/inconsistent data
click to copy
What is exception propagation in PL/SQL and how does it work across nested blocks?
When an exception is raised in an inner block PL/SQL searches for a handler in that block first; if not found the exception propagates to the enclosing outer block; if no handler is found at any level it propagates to the calling environment as an unhandled exception
click to copy
What is a PL/SQL package and what are its advantages over standalone procedures?
A package is a schema object that groups related PL/SQL types variables constants cursors exceptions procedures and functions into a single logical unit with a specification (public interface) and body (implementation); advantages: encapsulation state persistence via package variables improved performance and overloading
click to copy
What is invoker rights vs definer rights in PL/SQL stored procedures?
Definer rights (default): procedure executes with the privileges of the owner/definer regardless of who calls it. Invoker rights (AUTHID CURRENT_USER): procedure executes with the privileges of the caller enforcing caller-specific access controls; Invoker rights: better security (no privilege escalation) Definer rights: simpler deployment
click to copy
What is dynamic SQL with REF CURSOR and BULK COLLECT pattern in PL/SQL?
Opens a REF CURSOR for a dynamically-built SQL query then uses BULK COLLECT to fetch all rows into a collection in a single context switch combining the flexibility of dynamic SQL with the bulk processing performance of BULK COLLECT
click to copy
What is pipelined table function in PL/SQL?
A function that returns rows incrementally (one at a time) rather than building the entire result collection in memory before returning; the SELECT statement can begin processing rows as they are produced by PIPE ROW enabling streaming and reducing memory requirements
click to copy
What is the %TYPE and %ROWTYPE attribute in PL/SQL and why is it preferred?
Pct TYPE: declares a variable with the same data type as a specific column automatically adapting if the column type changes. Pct ROWTYPE: declares a record with the same structure as a table row or cursor result with fields matching all column names and types
click to copy
What is conditional compilation in PL/SQL?
A preprocessor feature that uses $IF/$ELSIF/$ELSE/$END IF directives evaluated at compile time to include or exclude code sections; used for: maintaining different versions of code for different environments (dev/test/prod) including debug logging in dev only handling version-specific features
click to copy
What is the UTL_FILE package in PL/SQL and what security measure controls its usage?
A package that provides PL/SQL access to OS filesystem files (read and write) allowing PL/SQL programs to read/write files on the database server; security controlled by the DIRECTORY object which must be granted to users - prevents access to arbitrary paths
click to copy
What is the DBMS_SCHEDULER package in Oracle PL/SQL and how does it improve upon DBMS_JOB?
A comprehensive job scheduling framework supporting: complex schedules (calendaring syntax: FREQ=DAILY;BYHOUR=2;BYMINUTE=0) job chains (workflow) job classes with resource limits event-based job triggering and detailed job logging - more feature-rich and reliable than the simpler DBMS_JOB package
click to copy
What is the NOCOPY hint in PL/SQL parameter passing and when should it be used?
A PL/SQL performance hint that passes OUT/IN OUT parameters by reference instead of by default copy (pass by value) avoiding expensive copying of large collections/records; should be used when: parameters are large (LOBs big collections) and the overhead of copying would be significant
click to copy
What is the cursor FOR loop in PL/SQL and what makes it superior to manual OPEN-FETCH-CLOSE?
A cursor FOR loop automatically handles OPEN FETCH and CLOSE operations and declares an implicit record variable reducing boilerplate code and eliminating the risk of forgetting to close cursors; also allows implicit cursor (inline SELECT) without a named cursor declaration
click to copy
What is the DETERMINISTIC clause on a PL/SQL function and how does it affect performance?
A clause indicating that the function always returns the same result for the same input parameters allowing Oracle to: cache the result and skip re-execution for duplicate inputs within a SQL statement enable use in function-based indexes and skip re-execution for same inputs in a query
click to copy
What is the RESULT_CACHE clause on a PL/SQL function and how does it differ from DETERMINISTIC?
RESULT_CACHE: Oracle caches function results in the SGA result cache shared across sessions with automatic invalidation when dependent tables change. DETERMINISTIC: hints to Oracle that results can be cached within a single SQL statement/query no cross-session sharing no automatic invalidation on table changes
click to copy
What is the DBMS_CRYPTO package in PL/SQL and how does it support application-level encryption?
A PL/SQL package providing cryptographic functions: symmetric encryption/decryption (AES 3DES DES) hashing (SHA-1 SHA-256 MD5) MAC generation and random key/data generation - enabling column-level application encryption separate from TDE
click to copy
What is the DBMS_OUTPUT package and what are its limitations in production systems?
A package for writing debug/informational messages to a server-side buffer that can be displayed by client tools like SQL Plus; limitations: buffer has a maximum size (default 20000 bytes max 1000000) messages only displayed AFTER the PL/SQL block completes (no streaming) not suitable for real-time monitoring and adds overhead
click to copy
What is the difference between static SQL and dynamic SQL in PL/SQL and when is each preferred?
Static SQL: SQL statements written directly in PL/SQL code at compile time (SELECT col INTO var FROM t WHERE id=x); validated and optimized at compile time gives better performance and error detection. Dynamic SQL (EXECUTE IMMEDIATE NDS): SQL constructed as strings at runtime; necessary when table/column names or statement type are not known until runtime but has higher overhead and risk of SQL injection if not using bind variables
click to copy
What is the FORALL statement and how does it differ from a regular FOR loop for DML operations?
FORALL sends the entire collection of DML operations to the SQL engine in a single context switch (one round-trip) vs. a regular FOR loop which sends each DML operation individually (one round-trip per iteration); FORALL is typically 10-100x faster for bulk DML because it eliminates N-1 context switches for N rows
click to copy
What is a PL/SQL record type and how does it differ from a collection?
A PL/SQL record type is a composite data type that groups related fields of different data types into a single structure (similar to a struct in C or row in a table); a collection is an ordered set of elements all of the same type. Records group heterogeneous fields; collections group homogeneous elements
click to copy

DBMS → Introduction to DBMS 7

What is the difference between DBMS and a file system at the concurrency level?
DBMS provides built-in concurrency control ensuring consistent simultaneous multi-user access; file systems provide no such mechanism leading to race conditions and data corruption under concurrent access
click to copy
What is the ER-to-relational mapping step in database design methodology?
The process of transforming a conceptual ER model into a concrete relational schema following systematic rules for entities, relationships, and attributes
click to copy
What is the three-tier architecture in the context of DBMS application development?
An architectural pattern separating applications into presentation tier (UI), application/logic tier (business rules), and data tier (DBMS); enables independent scaling, better security, and technology flexibility per tier
click to copy
What is database replication and what are the primary use cases?
The process of copying and maintaining database objects in multiple databases simultaneously; primary use cases: high availability (failover replica), read scalability (read replicas), geographic distribution, backup, and analytics reporting on replica
click to copy
What is a database cluster and how does it differ from a single database instance?
A group of database servers working together to provide higher availability, scalability, and fault tolerance than a single instance; includes shared-nothing clusters (sharding), shared-disk clusters (Oracle RAC), and active-passive failover clusters
click to copy
What is the concept of database abstraction layers (DAL) in application development?
A software layer between the application code and the database that abstracts specific database implementation details allowing the application to work with multiple database systems or switch databases without major code changes; examples include ORM frameworks and database adapter libraries
click to copy
What is data migration in the context of DBMS and what are the key challenges?
The process of transferring data between storage types, formats, or systems while ensuring data integrity, consistency, and completeness; key challenges include schema mapping differences, data type incompatibilities, referential integrity violations, handling NULL values, and performance for large datasets
click to copy

DBMS → Database Architecture 4

What is the difference between hot standby and warm standby in database high availability?
Hot standby: a replica that is continuously synchronized and can accept connections immediately on failover (seconds); warm standby: synchronized but not fully ready until activated (minutes); cold standby: requires restoration from backup (hours)
click to copy
What is database connection pooling and what problems does it solve?
A technique that maintains a pool of pre-established database connections that can be reused by application threads, avoiding the expensive cost of creating and destroying a new connection for each request; solves connection overhead, connection limits, and connection storms under high load
click to copy
What is read-write splitting in database architecture and what are the consistency trade-offs?
A pattern where write operations go to the primary database and read operations go to one or more replica databases; trade-off: replicas may lag behind primary so reads may return slightly stale data - applications must decide which reads require strong consistency versus which can tolerate stale data
click to copy
What is a database proxy and what functions does it serve in a database architecture?
A middleware component that sits between the application and the database server providing connection pooling, query routing (read-write splitting), load balancing, query caching, query filtering/firewall, and transparent failover without application changes
click to copy