SQL Interview Questions and Answers

August 25, 2017 | Author: vishwanathyadav649 | Category: Relational Database, Database Index, Databases, Sql, Database Transaction
Share Embed Donate


Short Description

Download SQL Interview Questions and Answers...

Description

www.fresherschoice.com

SQL INTERVIEW QUESTION AND ANSWERS Define Dbms? A Database Management system consists of a collection of interrelated data and set of programs to access that data.

Compare DBMS versus object oriented DBMS? DBMS consists of a collection of interrelated data and a set of programs to access that data. The object oriented DBMS is one of the type of dbms in which information is stored in the form of objects.

What is the purpose of Database systems? A Database Management system provides a secure and survivable medium for the storage and retrieval of data. In the real world, the data is shared among several users and is persistent.

What are the advantages of Database? Redundancy can be reduced Inconsistence can be avoided The data can be shared Standards can be enforced Security can be enforced Integrity can be maintained What is an active database? Active database is a database that includes active rules, mostly in the form of ECA rules (Event Condition rules). Active database systems enhance traditional database functionality with powerful rule processing capacities, providing a uniform and efficient mechanism for database system applications.

www.fresherschoice.com

www.fresherschoice.com

What is data mining? Data mining refers to using variety of techniques to identify nuggests of information or decision making knowledge in bodies of data and extracting these in such a way that they can be put in the use in the areas such as decision support, predication, forecasting and estimation. Define SQL? Structured query language is the standard command set used to communicate with the relational database management system.

What are the advantages of SQL? The advantages of SQL are SQL is a high level language that provides a greater degree of abstraction than procedural languages. SQL enables the end users and system personnel to deal with a number of Database management systems where it is available. Application written in SQL can be easily ported across systems. What is meant by embedded SQL? They are SQL statements that are embedded within application program and are prepared during the program preparation process before the program is executed. After it is prepared, the statement itself does not change (although values of host variables specified within the statement might change).

State the different between Security and Integrity? Security is a protection from malicious attempts to steal or modify data. Integrity constraints guard against accidental damage to the database, by ensuring that authorized changes to the database do not result in a loss of data consistency.

Define Normalisation? Normalisation is an essential part of database design. A good understanding of the semantic of data helps the designer to built efficient design using the concept of normalization. www.fresherschoice.com

www.fresherschoice.com

What is the purpose of Normalisation? Minimize redundancy in data. Remove insert, delete and update anamoly during the database activities. Reduce the need to reorganize data it is modified or enhanced. Define View? A View is a database object that is a logical representation of a table. It is derived from a table but has no longer of its own and often may be used in the same manner as a table. A view is a virtual table that has columns similar to a table. A view does not represent any physical data. Define Primary Key? The primary key is the columns used to uniquely identify each row of a table. A table can have only one primary key. No primary key value can appear in more than one row in the table. Define Foreign Key? A foreign Key is a combination of columns with value is based on the primary key values from another table. A foreign key constraint also known as Referential Integrity Constraint. Define Unique Key? Unique key is a one or more column that must be unique for each row of the table. It is similar to primary key. Primary key column will not accept a null. Whereas the unique key column will accept a null values. What is the difference between a primary key and a unique key? Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn’t allow NULLs, but unique key allows one NULL only.

www.fresherschoice.com

www.fresherschoice.com

What is cursor? Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, instead of the typical SQL commands that operate on all the rows in the set at one time.

Define View? A View is a database object that is a logical representation of a table. It is derived from a table but has no longer of its own and often may be used in the same manner as a table. A view is a virtual table that has columns similar to a table. A view does not represent any physical data. Compare and contrast TRUNCATE and DELETE for a table? Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The difference between the two is that the truncate command is a DDL operation and just moves the high water mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will produce a rollback and thus take longer to complete. Define Sub Query? Nesting of Queries one within the other is called as a Subquery. A table can have only one primary key. What are the different types of sub query? Single row sub query Multiple row sub query Correlated row sub query What are the different types of replication? The SQL Server 2000-supported replication types are as follows Transactional Snapshot Merge

www.fresherschoice.com

www.fresherschoice.com

Define Sequence? A Sequence is a database object that can be used to provide very quick generation of unique numbers. What is User Defined Functions? User-Defined Functions allow to define its own T-SQL functions that can accept 0 or more parameters and return a single scalar data value or a table data type. Define Joins? A Join combines columns and data from two or more tables (and in rare cases, of one table with itself). What are the types of Joins? Equi joins Cartesian Joins Outer Joins Self Joins. Define Self Join? Self join means joining one table with itself. The self join can be viewed as a join of two copies of the same table. Define Cartesian Join? Joining two tables without a where clause produces a Cartesian join which combines every row in one table with every row in another table. Define Equi Joins? A Equi Join is a join in which the join comparison operator is an equality. When two tables are joined together using equality or values in one or more columns, they make an Equi Join. What are three SQL keywords used to change or set someone's permissions? GRANT DENY REVOKE www.fresherschoice.com

www.fresherschoice.com

What are primary keys and foreign keys? Primary keys are the unique identifiers for each row. They must contain unique values and cannot be null. Due to their importance in relational databases, Primary keys are the most fundamental of all keys and constraints. A table can have only one Primary key. Foreign keys are both a method of ensuring data integrity and a manifestation of the relationship between tables. Explain the use of the by GROUP BY and the HAVING clause? The GROUP BY partitions the selected rows on the distinct values of the column on which the group by has been done. The HAVING selects groups which match the criteria specified. What is the difference between join and outer join? Outer joins return all rows from at least one of the tables or views mentioned in the FROM clause, as long as those rows meet any WHERE or HAVING search conditions. A join combines columns and data from two are more tables. Define Self Join? Self join means joining one table with itself. The self join can be viewed as a join of two copies of the same table. What is a query? A query with respect to DBMS relates to user commands that are used to interact with a data base. The query language can be classified into data definition language and data manipulation language. Define transaction? A collection of operations that form a single logical unit of works are called transaction. What are the transaction properties? Atomicity Consistency Isolation Durability www.fresherschoice.com

www.fresherschoice.com

What is Transaction Manager? It is a program module, which ensures that database, remains in a consistent state despite system failures and concurrent transaction execution proceeds without conflicting. What are the types of SQL Commands? Data Definition Language (DDL) Data Manipulation Language (DML) Data Query Language (DQL) Data Control Language (DCL) What is DDL (Data Definition Language)? A data base schema is specifies by a set of definitions expressed by a special language called DDL. What is the use of DBCC commands? DBCC stands for database consistency checker. We use these commands to check the consistency of the databases, i.e., maintenance, validation task and status checks. What are the different types of data models? Entity relationship model Relational model Hierarchical model Network model Object oriented model Object relational model What is an attribute? An entity is represented by a set of attributes. Attributes are descriptive properties possessed by each member of an entity set. There are different types of attributes. Simple Composite Single-valued Derived www.fresherschoice.com

www.fresherschoice.com

What are ACID properties? Atomicity Consistency Isolation Durability What are the different phases of transaction? The different phases of transaction are Analysis phase Redo Phase Undo phase What is a tuple? A tuple is an instance of data within a relational database. What is difference between Co-related sub query and nested sub query? Correlated sub query runs once for each row selected by the outer query. It contains a reference to a value from the row selected by the outer query. Nested sub query runs only once for the entire nesting (outer) query. It does not contain any reference to the outer query row. What the difference between UNION and UNIONALL? Union will remove the duplicate rows from the result set while Union all does’nt. What is a deadlock? Two processes waiting to update the rows of a table which are locked by the other process then deadlock arises.

What is Collation? Collation refers to a set of rules that determine how data is sorted and compared. Character data is sorted using rules that define the correct character sequence, with options for specifying casesensitivity, accent marks, kana character types and character width. www.fresherschoice.com

www.fresherschoice.com

What are different types of Collation Sensitivity? The different phases of transaction are Case sensitivity Accent sensitivity Kana Sensitivity Width sensitivity What is Cross Join? A cross join that does not have a WHERE clause produces the Cartesian product of the tables involved in the join. The size of a Cartesian product result set is the number of rows in the first table multiplied by the number of rows in the second table. What is Weak Entity set? An entity set may not have sufficient attributes to form a primary key, and its primary key compromises of its partial key and primary key of its parent entity, then it is said to be Weak Entity set. What is a trigger? Triggers are stored procedures created in order to enforce integrity rules in a database. A trigger is executed every time a data-modification operation occurs (i.e., insert, update or delete). Triggers are executed automatically on occurance of one of the data-modification operations. What is database Trigger? A database trigger is a PL/SQL block that can defined to automatically execute for insert, update, and delete statements against a table. The trigger can e defined to execute once for the entire statement or once for every row that is inserted, updated, or deleted. What is Storage Manager? It is a program module that provides the interface between the low-level data stored in database, application programs and queries submitted to the system. What is OLTP? Online Transaction Processing (OLTP) relational databases are optimal for managing changing data. When several users are performing transactions at the same time, OLTP databases are designed to let transactional applications write only the data needed to handle a single transaction as quickly as possible. www.fresherschoice.com

www.fresherschoice.com

What is the difference between a HAVING CLAUSE and a WHERE CLAUSE? HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause. Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is applied to each row before they are part of the GROUP BY function in a query. What is Index? An index is a physical structure containing pointers to the data. Indices are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. What is the difference between clustered and a non-clustered index? A Clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages. A Nonclustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a nonclustered index does not consist of the data pages. Instead, the leaf nodes contain index rows. What is an Integrity Constrains? An integrity constraint is a declarative way to define a business rule for a column of a table. What is Table? A table is the basic unit of data storage in an ORACLE database. The tables of a database hold all of the user accessible data. Table data is stored in rows and columns. What is a synonym? A synonym is an alias for a table, view, sequence or program unit. What are the types of Synonyms? There are two types of Synonyms are : Private Public

www.fresherschoice.com

www.fresherschoice.com

What does COMMIT do? A Commit makes permanent the changes resulting from all SQL statements in the transaction. The changes made by the SQL statements of a transaction become visible to other user sessions transactions that start only after transaction is committed. What are Roles? Roles are named groups of related privileges that are granted to users or other roles. What is SQLPlus? SQLPlus is an application that recognizes & executes SQL commands & specialized SQL*Plus commands that can customize reports, provide help & edit facility & maintain system variables What is the difference between normalization and denormalization? Normalizing data means eliminating redundant information from a table and organizing the data so that future changes to the table are easier. Denormalization means allowing redundancy in a table. The main benefit of denormalization is improved performance with simplified data retrieval and manipulation. What is the difference between static and dynamic SQL? Static SQL is hard-coded in a program when the programmer knows the statements to be executed. Dynamic SQL the program must dynamically allocate memory to receive the query results. What is NOT NULL Constraint? A NOT NULL constraint enforces that the column will not accept null values. The not null constraints are used to enforce domain integrity, as the check constraints. What is meant by query optimization? The phase that identifies an efficient execution plan for evaluating a query that has the least estimated cost is referred to as query optimization. What is UNIQUE KEY constraint? A UNIQUE constraint enforces the uniqueness of the values in a set of columns, so no duplicate values are entered. The unique key constraints are used to enforce entity integrity as the primary key constraints. www.fresherschoice.com

www.fresherschoice.com

What is meant by embedded SQL? They are SQL statements that are embedded within application program and are prepared during the program preparation process before the program is executed. What is File Manager? It is a program module, which manages the allocation of space on disk storage and data structure used to represent information stored on a disk. Define Constraints? A constraint is a rule or restriction concerning a piece of data that is enforced at the data level. A Constraint clause can constrain a single column or group of columns in a table. There are five types of Constraint namely Null / Not Null Primary Key Unique Check or Validation Foreign Key or References Key Describe the three levels of data abstraction? There are three levels of abstraction: Physical level : The lowest level of abstraction describes how data are stored. Logical level: The next higher level of abstraction, describes what data are stored in database and what relationship among those data. View level: The highest level of abstraction describes only part of entire database.

www.fresherschoice.com

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF