0% found this document useful (0 votes)
11 views6 pages

24 SQL Questions

The document provides an overview of various database concepts, including constraints, data integrity, auto increment, indexing, and data warehousing. It explains SQL operations such as joins, user-defined functions, collation, stored procedures, and transaction processing. Additionally, it covers SQL commands for data manipulation and retrieval, including UNION, MINUS, INTERSECT, and pattern matching.

Uploaded by

ridhidas24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

24 SQL Questions

The document provides an overview of various database concepts, including constraints, data integrity, auto increment, indexing, and data warehousing. It explains SQL operations such as joins, user-defined functions, collation, stored procedures, and transaction processing. Additionally, it covers SQL commands for data manipulation and retrieval, including UNION, MINUS, INTERSECT, and pattern matching.

Uploaded by

ridhidas24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1. What is a constraint?

Constraint can be used to specify the limit on the data type of table. Constraint can be
specified while creating or altering the table staternent. Constraint are

NOT NULL

CHECK

DEFAULT.

UNIQUE

PRIMARY KEY.

FOREIGN KEY.

2. What is data integrity?

Data integrity defines the accuracy and consistency of data stored in a database. It can
also define integrity constraints to enforce business rules on the data when it is entered
into the application or database.

3. What is Auto Increment?

Auto increment keyword allows the user to create a unique number to be generated when a
new record is inserted into the table. AUTO INCREMENT keyword can be used in Oracle and
IDENTITY keyword can be used in SQL SERVER Mostly this keyword can be used whenever
PRIMARY KEV is used.

4. What is the difference between Cluster and Non-Cluster index?

Clustered index is used for easy retrieval of data from the database by altering the way that
the records are stored. Database sorts out rows by the column which is set to be clustered
inclex. A nonclustered index does not alter the way it was stored but creates a complete
separate object within the table. It point back to the original table rows after searching.

5. What is Datawarehouse?
Datawarehouse is a central repository of data from multiple sources of information. Those
data are consolidated, transformed and made available for the mining and online
processing. Warehouse data have a subset of data called Data Marts.

6. What Is Self-Join?

Self-join is set to be query used to compare to itself. This is used to compare values in a
column with other values in the same column in the same table. ALIAS ES can be used for
the same table comparison.

7. What is Cross-Join?

Cross join defines as Cartesian product where number of rows in the first table multiplied
by number of rows in the second table. If suppose, WHERE clause is used in cross join then
the query will work like an INNER JOIN.

8. What is user defined functions?

User defined functions are the functions written to use that logic whenever required. It is
not necessary to write the same logic several times. Instead function can be called or
executed whenever needed.

9. What are all types of user defined functions?

Three types of user defined functions are.

Scalar Functions.

Inline Table valued functions.

Multi statement valued functions.

Scalar retums unit, variant defined the return clause. Other two types retum toble as a
return.

10. What is collation?


Collation is defined as set of rules that determine how character data can be sorted and
compared. This can be used to compare A and other language characters and also
depends on the width of the characters. ASCII value can be used to compare these
character data.

11. What are all different types of collation sensitivity?

Following are different types of collation sensitivity-

Case Sensitivity-A and a and Band b

Accent Sensitivity.

Kana Sensitivity – Japanese Kana characters

Width Sensitivity-Single byte character and double byte character.

12. Advantages and Disadvantages of Stored Procedure?

Stored procedure can be used as a modular programming means create once, store and
call for several times whenever required. This supports faster execution instead of
executing multiple queries. This reduces network traffic and provides better security to the
data. Disadvantage is that it can be executed only in the Database and utilizes more
memory in the database server.

13. What is Online Transaction Processing (OLTP)?

Online Transaction Processing (OLTP) manages transaction based applications which can
be used for data entry, data retrieval and data processing. OLTP makes data management
simple and efficient. Unlike OLAP systems goal of OLTP systems is serving real-time
transactions

Example-Bank Transactions on a daily basis.

14. What is CLAUSE?

SQL clause is defined to limit the result set by providing condition to the query. This usually
filters some rows from the whole set of records.
Example-Query that has WHERE condition Query that has HAVING condition.

15. What is recursive stored procedure?

A stored procedure which calls by itself until it reaches some boundary condition. This
recursive function or procedure helps programmers to use the same set of code any
number of times.

16. What is Union, minus and interact commands?

UNION operator is used to combine the results of two tables, and it eliminates duplicate
rows from the tables.

MINUS operator is used to return rows from the first query but not from the second query.

Matching records of first and second query and other rows from the first query will be
displayed as a result set

INTERSECT operator is used to return rows returned by both the queries.

17. What is an ALIAS command?

ALIAS name can be given to a table or column. This alias name can be referred in WHERE
clause to identify the table or column

Example- Select st. StudentiD, Ex Result from student st, Exam as Ex where st studentID =
Ex StudentiD. Here, st refers to alias name for student table and Ex refers to alias name for
exam table.

18. What is the difference between TRUNCATE and DROP statements?

TRUNCATE removes all the rows from the table, and it cannot be rolled back

DROP command removes a table from the database and operation cannot be rolled back

19. What are aggregate and scalar functions?


Aggregate functions are used to evaluate mathematical calculation and return single
values. This can be calculated from the columns in a table. Scalar functions retum a single
value based on the input value.

20. How can you create an empty table from an existing table? Example will be Select into
studentcopy from student where 1-2

Here, we are copying student table to another table with the same structure with no rows
copied.

21. How to fetch common records from two tables?

Common records result set can be achieved by-

Select studentiD from student, <strong>INTERSECT/strong> Select StudentiD from Exam

22. How to fetch alternate records from a table?

Records can be fetched for both Odd and Even row numbers-

To display even numbers-

Select studentid from (Select rowno, studentid from student) where

Mod(rowno,2)=0.

To display odd numbers-

Select studentid from (Select rowno, studentid from student) where from (Select rowno,
studentid from student) where mod(rowno,2)=1.[/sql]

23. How to select unique records from a table?

Select unique records from a table by using DISTINCT keyword. Select DISTINCT
StudentID, StudentName from Student.

24. What is the command used to fetch first 5 characters of the string?
There are many ways to fetch first 5 characters of the string- Select
SUBSTRING(StudentName, 15) as studentname from student Select RIGHT
(Studentname,5) as studentname from student

25. Which operator is used in query for pattern matching? LIKE operator is used for pattern
matching, and it can be used as –

1.%-Matches zero or more characters.

2. (Underscore)-Matching exactly one character.

Example-

Select from Student where studenthame like ‘a%” Select from Student where studentname
like ‘ami_’

You might also like