0% found this document useful (0 votes)
102 views

SQL Interview Questions 2021

1. The document discusses Structured Query Language (SQL) interview questions and answers. SQL is a database language used to create, access, and manage data in relational database management systems (RDBMS). 2. Key concepts covered include SQL constraints like NOT NULL, DEFAULT, UNIQUE, PRIMARY KEY, and FOREIGN KEY; database normalization forms like 1NF, 2NF, and 3NF; and database objects like tables, fields, indexes, and functional dependencies. 3. Examples are provided for how to define SQL constraints in a table creation statement and how to normalize a table to third normal form to eliminate transitive dependencies between attributes.

Uploaded by

K RUKESH
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views

SQL Interview Questions 2021

1. The document discusses Structured Query Language (SQL) interview questions and answers. SQL is a database language used to create, access, and manage data in relational database management systems (RDBMS). 2. Key concepts covered include SQL constraints like NOT NULL, DEFAULT, UNIQUE, PRIMARY KEY, and FOREIGN KEY; database normalization forms like 1NF, 2NF, and 3NF; and database objects like tables, fields, indexes, and functional dependencies. 3. Examples are provided for how to define SQL constraints in a table creation statement and how to normalize a table to third normal form to eliminate transitive dependencies between attributes.

Uploaded by

K RUKESH
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

COLLEGE OF ENGINEERING AND TECHNOLOGY

Department of Computer Science and Engineering

SQL Interview Questions


1. What is SQL?
Structured Query Language SQL is a database tool that is used to create and access the database to
support software applications.
A Database computer Language designed for Managing Data in RDBMS

 MS SQL Server using T-SQL,


 Oracle using PL/SQL,
 MS Access version of SQL is called JET SQL (native format) etc.

2. What is RDBMS?
RDBMS stands for Relational Database Management System.
RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2,
Oracle, My SQL, and Microsoft Access.

The data in an RDBMS is stored in database objects which are called as tables
Relation- table
Tuple- row
Attribute- column
What is table - The data in RDBMS is stored in database objects called tables.
-
What is field Every table is broken up into smaller entities called fields. The fields in the
CUSTOMERS table consist of ID, NAME, AGE, ADDRESS and SALARY.

SQL Constraints
Constraints are used to limit the type of data that can go into a table.
Constraints can be specified when a table is created (with the CREATE TABLE statement) or
After he table is created (with the ALTER TABLE statement).
Here are the most important constraints:

 NOT NULL Constraint: Ensures that a column cannot have NULL value.
 DEFAULT Constraint: Provides a default value for a column when none is specified.
 UNIQUE Constraint: Ensures that all values in a column are different.
 PRIMARY Key: Uniquely identified each rows/records in a database table.
 FOREIGN Key: Uniquely identified a rows/records in any another database table.
 CHECK Constraint: The CHECK constraint ensures that all values in a column satisfy certain
conditions.
 INDEX: Use to create and retrieve data from the database very quickly.

3. NOT NULL Constraint :


A NULL is not the same as no data, rather, it represents unknown data.

CREATE TABLE CUSTOMERS(


ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);

4. DEFAULT Constraint:
The DEFAULT constraint provides a default value to a column when the INSERT INTO statement
does not provide a specific value.

CREATE TABLE CUSTOMERS(


ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2) DEFAULT 5000.00,
PRIMARY KEY (ID)
);
5. UNIQUE Constraint:
The UNIQUE Constraint prevents two records from having identical values in a particular column more people from
having identical age

CREATE TABLE CUSTOMERS(


ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL UNIQUE,
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);
6. PRIMARY Key:
A primary key is a field in a table which uniquely identifies each row/record in a database table.
Primary keys must contain unique values. A primary key column cannot have NULL values.

A table can have only one primary key, which may consist of single or multiple fields. When
multiple fields are used as a primary key, they are called a composite key.
CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);

7. FOREIGN Key:
Foreign Key is a column or a combination of columns whose values match a Primary Key in a
different table.

The relationship between 2 tables matches the Primary Key in one of the tables with a
Foreign Key in the second table.

CUSTOMERS table:
CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);

ORDERS table:
CREATE TABLE ORDERS (
ID INT NOT NULL,
DATE DATETIME,
CUSTOMER_ID INT references CUSTOMERS(ID),
AMOUNT double,
PRIMARY KEY (ID)
);

8. CHECK Constraint:
The CHECK Constraint enables a condition to check the value being entered into a record. If the
condition evaluates to false, the record violates the constraint and isn’t entered into the table.

Example:
CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL CHECK (AGE >= 18),
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);

9. INDEX:
The INDEX is used to create and retrieve data from the database very quickly. Index can be created
by using single or group of columns in a table.
syntax:

CREATE INDEX index_name ON table_name ( column1, column2.....);

To create an INDEX on AGE column, to optimize the search on customers for a particular age, following is the SQL
Example :

CREATE INDEX id x_age ON CUSTOMERS ( AGE );

Database Normalization
Database normalization is the process of efficiently organizing data in a database. There
are two reasons of this normalization process:

 Eliminating redundant data. For example, storing the same data in more than one table.
 Ensuring data dependencies make sense.

10. First Normal Form (1NF)


 Only atomic attributes (simple, single-value)
 A primary key has been identified
 Every relation is in 1NF by definition

1NF example:

StudentId StuName CourseId CourseName Grade


100 Mike 112 C++ A
100 Mike 111 Java B
101 Susan 222 Database A
140 Lorenzo 224 Graphics B

11. Functional Dependency: The value of one attribute (the determinant) determines the value
of another attribute.
AB reads “Attribute B is functionally dependent on A”
AB means if two rows have same value of A they necessarily have same value of B
FDs are determined by semantics: You can’t say that a FD exists just by looking at data.
But can say whether it does not exist by looking at data.

• Id  Name?
• Age  Gender?
• Name  Id?
• Name, Age  Id?
Functional Dependencies and Keys
Functional Dependency: The value of one attribute (thedeterminant) determines the value of
another attribute.
12. Candidate Key :
 Attribute that uniquely identifies a row in a relation
 Could be a combination of (non-redundant) attributes
 Each non-key field is functionally dependent on every candidate key

13. Second Normal Form (2NF)


• 1NF PLUS every non-key attribute is fully functionally dependent on the ENTIRE
primary key
– Every non-key attribute must be defined by the entire key, not by only part of the key
– No partial functional dependencies
Functional Dependencies in Student

Can represent FDs with arrows as above, or


• StudentId StuName,
• CourseId CourseName
• StudentId,CourseId  Grade (and StuName, CourseName)

NOT in 2nd Normal Form!!


2NF: Normalizing
How do we convert the partial dependencies into normal ones ? By breaking into more
tables.

14. Third Normal Form


• 2NF and no transitive dependencies
• A transitive dependency is when a non-key attribute depends on another non-key attribute
• Note: This is called transitive, because the primary key is a determinant for another attribute,
which in turn is a determinant for a third attribute

3NF Example

Course SectNum Classroom Capacity

• ClassroomCapacity TRANSITIVE
• Any partial FDs? NO
• Any transitive FDs? YES !
• How do we eliminate it?
• By breaking into its own table

3NF Normalization

15. Boyce-Codd Normal form (BCNF)


 Slight difference with 3NF
 To be in 3NF but not in BNF, needs two composite candidate keys, with one attribute of one
key depending on one attribute of the other
 Not very common
 if a table contains only one candidate key, the 3NF and the BCNF are equivalent.

BCNF Example
Assume that
 For each subject, each student is taught by one Instructor
 Each Instructor teaches only one subject
 Each subject is taught by several Instructors
Course, Student  Instructor
Course Instructor Student Instructor  Course
CS 121 Dr. A. James Bill Payne
CS 121 Dr. A. James Tony Perez
CS 121 Dr. A. James James Atkinson
CS 121 Dr. A. James Linda Lee

Course Instructor Student Course Instructor Student


CS 141 Dr. T. Watson Linda Lee CS 101 Dr. M. Jones Linda Lee
CS 141 Dr. T. Watson Judith San CS 101 Dr. M. Jones Tony Perez
CS 141 Dr. T. Watson Bill Jones CS 101 Dr. M. Jones Bill Payne
CS 141 Dr. P. Hold Bill Payne
CS 141 Dr. P. Hold A. White
BCNF: Decompose into (Instructor, Course) and (Student, Instructor)
16. BCNF
Boyce-Codd normal form (BCNF)
A relation is in BCNF, if and only if, every determinant is a candidate key.
 The difference between 3NF and BCNF is that for a functional dependency A B, 3NF
allows this dependency in a relation if B is a primary-key attribute and A is not a candidate
key,
whereas BCNF insists that for this dependency to remain in a relation, A must be a candidate key.

17. 4NF
 A multi-valued dependency exists when
 There are at least 3 attributes A, B, C in a relation and
 For each value of A there is a well defined set of values for B, and a well defined set of
values for C,
 But the set of values for B is independent on the set of values for C

 4NF = 3NF with no multi-valued dependency

4NF Example
Assume that
 Each subject is taught by many Instructors
 The same books are used in many subjects
 Each Instructor uses a different book

Course, Instructor  Text


Course, Text  Instructor

Course Instructor Text


CS 121 Dr. A. James Int to Com Science
CS 121 Dr. P. Hold Comp Scien Int

Course Instructor Text


CS 141 Dr. T. Watson Int to Com Science
CS 141 Dr. P. Hold Comp Scien Int
CS 101 Dr. M. Jones COMP SCIEN

4NF: Decompose into (Course, Instructor) and (Course, Text)

SQL Fundamentals
Data Definition Language (DDL)
18. CREATE TABLE :
CREATE creates an object (a table, for example) in the database.

Syntax :
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY( one or more columns )
);

Example :
SQL> CREATE TABLE SALARY AS SELECT ID, SALARY FROM CUSTOMERS;

19.DROP
deletes an object in the database, usually irretrievably. (Deletes entire table)

Syntax:
DROP TABLE table_name;
Example:
SQL> DROP TABLE CUSTOMERS;

20.ALTER TABLE
ALTER TABLE command is used to add, delete or modify columns in an existing table.
Syntax:
The basic syntax of ALTER TABLE to add a new column in an existing table is as follows:
ALTER TABLE table_name ADD column_name datatype;

The basic syntax of ALTER TABLE to DROP COLUMN in an existing table is as follows:
ALTER TABLE table_name DROP COLUMN column_name;

The basic syntax of ALTER TABLE to change the DATA TYPE of a column in a table is as
follows:
ALTER TABLE table_name MODIFY COLUMN column_name datatype;

The basic syntax of ALTER TABLE to add a NOT NULL constraint to a column in a table is as
follow
ALTER TABLE table_name MODIFY column_name datatype NOT NULL;

The basic syntax of ALTER TABLE to ADD UNIQUE CONSTRAINT to a table is as follows:
ALTER TABLE table_name
ADD CONSTRAINT MyUniqueConstraint UNIQUE(column1, column2...);

The basic syntax of ALTER TABLE to ADD CHECK CONSTRAINT to a table is as follows:
ALTER TABLE table_name
ADD CONSTRAINT MyUniqueConstraint CHECK (CONDITION);

The basic syntax of ALTER TABLE to ADD PRIMARY KEY constraint to a table is as follows:
ALTER TABLE table_name
ADD CONSTRAINT MyPrimaryKey PRIMARY KEY (column1, column2...);

Example:
Consider the CUSTOMERS table having the following records

ID NAME AGE ADDRESS SALARY


1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00

ID NAME AGE ADDRESS SALARY GENDER


1 Ramesh 32 Ahmedabad 2000.00 NULL
2 Khilan 25 Delhi 1500.00 NULL

21.TRUNCATE TABLE

TRUNCATE TABLE command is used to delete complete data from an existing table.
Syntax: TRUNCATE TABLE table_name;

Example to truncate: SQL > TRUNCATE TABLE CUSTOMERS;

DML - Data Manipulation Language:


INSERT : Creates a record
UPDATE : Modifies records
DELETE :Deletes records

22.INSERT

INSERT INTO Statement is used to add new rows of data to a table in the database.

Syntax:
INSERT INTO TABLE_NAME (column1, column2, column3,...columnN)] VALUES (value1,
value2, value3,...valueN);

Example:
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (1, 'Ramesh', 32, 'Ahmedabad', 2000.00 );

23.SELECT
SELECT Statement is used to fetch the data from a database table which returns data in the
form of Result table.
Syntax:
SELECT column1, column2, columnN FROM table_name;
SELECT * FROM table_name;
Example:

ID NAME AGE ADDRESS SALARY GENDER


1 Ramesh 32 Ahmedabad 2000.00 NULL
2 Khilan 25 Delhi 1500.00 NULL

24. UPDATE
UPDATE Query is used to modify the existing records in a table.
Syntax:
UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];

Example:
ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 kaushik 23 Kota 2000.00

update ADDRESS for a customer whose ID is 3:

SQL> UPDATE CUSTOMERS


SET ADDRESS = 'Pune'
WHERE ID = 3;

ID NAME AGE ADDRESS SALARY


1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 kaushik 23 Pune 2000.00

25. DELETE
DELETE Query is used to delete the existing records from a table.
Syntax:
DELETE FROM table_name
Example:
DELETE FROM table_name

DCL - Data Control Language:


GRANT Gives a privilege to user
REVOKE Takes back privileges granted from user

26.GRANT :Grant permission to drop any table


As the title suggests, if you want to allow user to drop any table from the database, then
grant this privilege to the user,

GRANT DROP ANY TABLE TO username

27.REVOKE :To take back Permissions


if you want to take back the privileges from any user, use the REVOKE command.

REVOKE CREATE TABLE FROM username

Transaction Control:
There are following commands used to control transactions:
 COMMIT: to save the changes.
 ROLLBACK: to rollback the changes.
 SAVEPOINT: creates points within groups of transactions in which to ROLLBACK

28. The COMMIT Command:


The COMMIT command is the transactional command used to save changes invoked by a
transaction to the database.

Syntax:COMMIT;
Example:
SQL> DELETE FROM CUSTOMERS
WHERE AGE = 25;
SQL> COMMIT;

29. The ROLLBACK Command:


The ROLLBACK command is the transactional command used to undo transactions that
have not already been saved to the database.

Syntax : ROLLBACK;
Example:
SQL> DELETE FROM CUSTOMERS
WHERE AGE = 25;
SQL> ROLLBACK;

30.SAVEPOINT :
A SAVEPOINT is a point in a transaction when you can roll the transaction back to a certain
point without rolling back the entire transaction.

Syntax :
SAVEPOINT SAVEPOINT_NAME;
Example :
SQL> SAVEPOINT SP1;
Savepoint created.
SQL> DELETE FROM CUSTOMERS WHERE ID=1;1 row deleted.

SQL Join Types:


INNER JOIN: returns rows when there is a match in both tables.
LEFT JOIN: returns all rows from the left table, even if there are no matches in the right
table.
RIGHT JOIN: returns all rows from the right table, even if there are no matches in the left
table.
FULL JOIN: returns rows when there is a match in one of the tables.
SELF JOIN: is used to join a table to itself as if the table were two tables, temporarily
renaming at least one table in the SQL statement.
CARTESIAN JOIN: returns the Cartesian product of the sets of records from the two or
more joined tables.

31. INNER JOIN: The INNER JOIN creates a new result table by combining column values of
two tables (table1 and table2) based upon the join-predicate
Syntax:
SELECT table1.column1, table2.column2...
FROM table1
INNER JOIN table2
ON table1.common_filed = table2.common_field;

Example:
SQL> SELECT ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
INNER JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

32. LEFT JOIN :


LEFT JOIN returns all rows from the left table, even if there are no matches in the right
table
Syntax:
SELECT table1.column1, table2.column2...
FROM table1
LEFT JOIN table2
ON table1.common_filed = table2.common_field;

Example:
SQL> SELECT ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
LEFT JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

33.RIGHT JOIN:
RIGHT JOIN returns all rows from the right table, even if there are no matches in the left
table
Syntax:
SELECT table1.column1, table2.column2...
FROM table1
RIGHT JOIN table2
ON table1.common_filed = table2.common_field;

Example:
SQL> SELECT ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
RIGHT JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

34.FULL JOIN
The SQL FULL JOIN combines the results of both left and right outer joins.

Syntax:
SELECT table1.column1, table2.column2...
FROM table1
FULL JOIN table2
ON table1.common_filed = table2.common_field;

Example:
SQL> SELECT ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
FULL JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

35.SELF JOIN
The SQL SELF JOIN is used to join a table to itself as if the table were two tables,
temporarily renaming at least one table in the SQL statement.

Syntax:
SELECT a.column_name, b.column_name...
FROM table1 a, table1 b
WHERE a.common_filed = b.common_field;

Example:
SQL> SELECT a.ID, b.NAME, a.SALARY
FROM CUSTOMERS a, CUSTOMERS b
WHERE a.SALARY < b.SALARY;

36.CARTESIAN JOIN
The CARTESIAN JOIN or CROSS JOIN returns the cartesian product of the sets of records
from the two or more joined tables.

Syntax:
SELECT table1.column1, table2.column2...
FROM table1, table2 [, table3 ]

Example:
SQL> SELECT ID, NAME, AMOUNT, DATE
FROM CUSTOMERS, ORDERS;

37. ORDER BY Clause


ORDER BY clause is used to sort the data in ascending or descending order, based on one
or
more columns. Some database sorts query results in ascending order by default.
Syntax:
SELECT column-list
FROM table_name
[WHERE condition]
[ORDER BY column1, column2, .. columnN] [ASC | DESC];

Example :
SQL> SELECT * FROM CUSTOMERS
ORDER BY NAME, SALARY;

38. Group By :
GROUP BY clause is used in collaboration with the SELECT statement to arrange identical
data into groups

Syntax:
SELECT column1, column2
FROM table_name
WHERE [ conditions ]
GROUP BY column1, column2

Example:
SQL> SELECT NAME, SUM(SALARY) FROM CUSTOMERS GROUP BY NAME;

39. Distinct Keyword


SQL DISTINCT keyword is used in conjunction with SELECT statement to eliminate all the
duplicate records and fetching only unique records.

Syntax:
SELECT DISTINCT column1, column2,.....columnN
FROM table_name WHERE [condition]
Example:
SQL> SELECT SALARY FROM CUSTOMERS ORDER BY SALARY;

40. HAVING CLAUSE:


HAVING clause enables you to specify conditions that filter which group results appear in
the final results.

Syntax: SELECT column1, column2


FROM table1, table2
WHERE [ conditions ]
GROUP BY column1, column2
HAVING [ conditions ]
ORDER BY column1, column2

Example:
SQL > SELECT *
FROM CUSTOMERS
GROUP BY age
HAVING COUNT(age) >= 2;

41. Alias Syntax


you can rename a table or a column temporarily by giving another name known as alias.

Syntax: The basic syntax of table alias is as follows:


SELECT column1, column2....
FROM table_name AS alias_name
WHERE [condition];

The basic syntax of column alias is as follows:


SELECT column_name AS alias_name
FROM table_name
WHERE [condition];

Example: , following is the usage of table alias:


SQL> SELECT C.ID, C.NAME, C.AGE, O.AMOUNT
FROM CUSTOMERS AS C, ORDERS AS O
WHERE C.ID = O.CUSTOMER_ID;

Following is the usage of column alias:

SQL> SELECT ID AS CUSTOMER_ID, NAME AS CUSTOMER_NAME


FROM CUSTOMERS
WHERE SALARY IS NOT NULL;
42. Wildcard Operators : LIKE operator

The percent sign (%) : Matches one or more characters. Note that MS Access uses the
asterisk (*) wildcard
character instead of the percent sign (%) wildcard character

The underscore (_) : Matches one character. Note that MS Access uses a question mark (?)
instead of the
underscore (_) to match any one character.

Syntax:
The basic syntax of ‘%’ and ‘_’ is as follows:

SELECT FROM table_name


WHERE column LIKE 'XXXX%'
Example:
WHERE SALARY LIKE '200%' :Finds any values that start with 200
WHERE SALARY LIKE '_00%' : Finds any values that have 00 in the second and third positions

43.Triggers
A database trigger is code that is automatically executed in response to certain events on a
n particular table in a database.

Syntax for creating a Trigger:

CREATE TRIGGER <TriggerName> on <TableName>


FOR INSERT, UPDATE, DELETE
AS
… Create your Code here
GO

Example :
IF EXISTS (SELECT name
FROM sysobjects
WHERE name = 'CheckPhoneNumber'
AND type = 'TR')
DROP TRIGGER CheckPhoneNumber
GO

CREATE TRIGGER CheckPhoneNumber ON CUSTOMER


FOR UPDATE, INSERT
AS

44. . What are the properties of the transaction?


ACID properties
Atomicity: Ensures the completeness of all transactions performed. Checks whether every
transaction is completed successfully if not then transaction is aborted at the failure point
and the previous transaction is rolled back to its initial state as changes undone

Consistency: Ensures that all changes made through successful transaction are reflected
properly on database

Isolation: Ensures that all transactions are performed independently and changes made by
one transaction are not reflected on other

Durability: Ensures that the changes made in the database with committed transactions
persist as it is even after a system failure.

45. What do you mean by Collation?


Answer: Collation is defined as a set of rules that determine how data can be sorted as well
as compared.

46. What is a Subquery?


Answer: A Subquery is a SQL query within another query. It is a subset of a Select
statement whose return values are used in filtering the conditions of the main query.

47. What is a coalesce function?


Answer: Coalesce function is used to return the first, not NULL value out of the multiple
values or expressions passed to the coalesce function as parameters.
Example-
COALESCE(NULL, NULL, 5, ‘ArtOfTesting’) will return the value 5.
COALESCE(NULL, NULL, NULL) will return NULL value as no not NULL value is
encountered in the parameters list

48. How many Aggregate functions are available in SQL?


 AVG(): Returns the average value from specified columns.
 COUNT(): Returns number of table rows.
 MAX(): Returns the largest value among the records.
 MIN(): Returns smallest value among the records.
 SUM(): Returns the sum of specified column values.
 FIRST(): Returns the first value
 LAST(): Returns last value.

49. What is SQL Sandbox in SQL Server


 Safe Access Sandbox: Here a user can perform SQL operations such as creating
stored procedures, triggers etc. but cannot have access to the memory as well as
cannot create files.
 External Access Sandbox: Users can access files without having the right to
manipulate the memory allocation.
 Unsafe Access Sandbox: This contains untrusted codes where a user can have
access to memory.
50. What is a Cursor?
Answer: A cursor is a database object which is used to manipulate data in a row-to-row
manner.
Cursor follows steps as given below:
 Declare Cursor
 Open Cursor
 Retrieve row from the Cursor
 Process the row
 Close Cursor
 Deallocate Cursor
51. What is Database White Box Testing?
 Database Consistency and ACID properties
 Database triggers and logical views
 Decision Coverage, Condition Coverage, and Statement Coverage
 Database Tables, Data Model, and Database Schema
 Referential integrity rules

52. What is Database Black Box Testing?


 Data Mapping
 Data stored and retrieved
 Use of Black Box testing techniques such as Equivalence Partitioning and Boundary
Value Analysis (BVA)

53. Which TCP/IP port does SQL Server run?


By default SQL Server runs on port 1433.

54. Explain the difference between Rename and Alias?


Rename is a permanent name given to a table or column whereas Alias is a temporary
name given to a table or column.

55. What is schema?


A schema is a collection of database objects of a User.
56.ORACLE
It is a very large and multi-user database management system. Oracle is a relational
database management system developed by 'Oracle Corporation'.

Oracle works to efficiently manage its resource, a database of information, among the
multiple clients requesting and sending data in the network.

It is an excellent database server choice for client/server computing. Oracle supports all
major operating systems for both clients and servers, including MSDOS, NetWare,
UnixWare, OS/2 and most UNIX flavors.

You might also like