You are on page 1of 12

Accomplishment Oriented

contributed to, participated in, or helped out


with.
Analyzed new markets and explored
potential entrance strategies for China division
Quantifi able Results
Implemented crash reporter and used results to fi x
three biggest causes of crashes.
==========================================================
SQL concepts :
DBMS and RDBMS
All keys
Constraints
Joins
Referential integrity
Normalization and its diff forms
Views
Aggregate and scalar function
SQL operators
Index and types
Cursor
Sub queries and its types
Stored procedures
Trigger
User defined function and all types
DDL,DML,DCL,TCL
Set operators
Acid properties
Transactions
CTE(common table expression )
Relationships
Alias and synonyms
Collation
Data types
============================================================
Technical
1. Diff Char and varchar :-

1 CHAR datatype is used to store character VARCHAR datatype is used to store character string
string of fixed length of variable length

2. In CHAR, If the length of string is less than In VARCHAR, If the length of string is less than set
set or fixed length then it is padded with or fixed length then it will store as it is without
extra memory space. padded with extra memory spaces.

3. CHAR stands for “Character” VARCHAR stands for “Variable Character”

4. Storage size of CHAR datatypes is equal to Storage size of VARCHAR datatype is equal to the
n bytes i.e. set length actual length of the entered string in bytes.

5. We should use CHAR datatype when we We should use VARCHAR datatype when we expect
expect the data values in a column are of the data values in a column are of variable length.
same length.

6. CHAR take 1 byte for each character VARCHAR take 1 byte for each character and some
extra bytes for holding length information

9. Better performance than VARCHAR Performance is not good as compared to CHAR

2. Diff delete and truncate

1. The DELETE command is used to delete While this command is used to delete all the rows
specified rows(one or more). from a table.

2. It is a DML(Data Manipulation Language) While it is a DDL(Data Definition Language)


command. command.

3. There may be WHERE clause in DELETE While there may not be a WHERE clause in the
command in order to filter the records. TRUNCATE command.

4. In the DELETE command, a tuple is While in this command, data page is locked before
locked before removing it. removing the table data.

5. The DELETE statement removes rows TRUNCATE TABLE removes the data by
one at a time and records an entry in the deallocating the data pages used to store the table data
transaction log for each deleted row. and records only the page deallocations in the
transaction log.
6. DELETE command is slower than While TRUNCATE command is faster than DELETE
TRUNCATE command. command.

7. To use Delete you need DELETE To use Truncate on a table we need at least ALTER
permission on the table. permission on the table.

8. Identity of column retains the identity Identity of the column is reset to its seed value if the
after using DELETE Statement on table. table contains an identity column.

9. The delete can be used with indexed Truncate cannot be used with indexed views.
views.

3. Diff cluster and non cluster index

Clustered index is faster. Non-clustered index is slower.

Clustered index requires less memory for Non-Clustered index requires more memory for
operations. operations.

In clustered index, index is the main data. In Non-Clustered index, index is the copy of data.

A table can have only one clustered index. A table can have multiple non-clustered index.

Clustered index has inherent ability of Non-Clustered index does not have inherent ability of
storing data on the disk. storing data on the disk.

Clustered index store pointers to block not Non-Clustered index store both value and a pointer to
data. actual row that holds data.

In Clustered index leaf nodes are actual data In Non-Clustered index leaf nodes are not the actual
itself. data itself rather they only contains included columns.

In Clustered index, Clustered key defines In Non-Clustered index, index key defines order of data
order of data within table. within index.

A Clustered index is a type of index in A Non-Clustered index is a special type of index in


which table records are physically reordered which logical order of index does not match physical
to match the index. stored order of the rows on disk.

4. Sql query for current date


SELECT Sysdate AS System_date
FROM Dual

5. Diff between drop and truncate.

1. The DROP command is used to remove table Whereas the TRUNCATE command is used to
definition and its contents. delete all the rows from the table.

2. In the DROP command, table space is freed While the TRUNCATE command does not free
from memory. the table space from memory.

3. DROP is a DDL(Data Definition Language) Whereas the TRUNCATE is also a DDL(Data


command. Definition Language) command.

4. In the DROP command, view of table does not While in this command, view of table exist.
exist.

5. In the DROP command, integrity constraints While in this command, integrity constraints will
will be removed. not be removed.

6. In the DROP command, undo space is not While in this command, undo space is used but
used. less than DELETE.

7. The DROP command is quick to perform but While this command is faster than DROP.
gives rise to complications.

6. Get count of record


Select count(record) from table_name

7. Any five aggregate function


1) Count()
2) Sum()
3) Avg()
4) Min()
5) Max()

8. Any five string manipulation function


1) Concat
2) Like
3) Lower
4) Lpad
5) Rpad
6) Rtrim

9. How to insert null value in column


While inserting values in the table specify null as a value.

10. Diff between (between and in ) condition


Between - it is used to get set of records ranging between two values
In - it is used to get record whose values columns values matches with given set of values

11. What is merge


The MERGE statement in SQL is a very popular clause that can handle inserts, updates, and
deletes all in a single transaction without having to write separate logic for each of these. ... The
MERGE statement tries to compare the source table with the target table based on a key field and
then do some of the processing.

12. What is clouse


A clause in SQL is a part of a query that lets you filter or customize how you want your
data to be queried to you.

13. Diff between having and where clause

1. WHERE Clause is used to filter the records HAVING Clause is used to filter record from
from the table based on the specified condition. the groups based on the specified condition.

2. WHERE Clause can be used without GROUP HAVING Clause cannot be used without
BY Clause GROUP BY Clause

3. WHERE Clause implements in row operations HAVING Clause implements in column


operation

4. WHERE Clause cannot contain aggregate HAVING Clause can contain aggregate
function function

5. WHERE Clause can be used with SELECT, HAVING Clause can only be used with
UPDATE, DELETE statement. SELECT statement.

6. WHERE Clause is used before GROUP BY HAVING Clause is used after GROUP BY
Clause Clause
7. WHERE Clause is used with single row function HAVING Clause is used with multiple row
like UPPER, LOWER etc. function like SUM, COUNT etc.

14. How to execute dynamic sql

15. Various levels of constraints


16. NOT NULL - Ensures that a column cannot have a NULL value
17. UNIQUE - Ensures that all values in a column are different
18. PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifies each row
in a table
19. FOREIGN KEY - Prevents actions that would destroy links between tables
20. CHECK - Ensures that the values in a column satisfies a specific condition
21. DEFAULT - Sets a default value for a column if no value is specified
22. CREATE INDEX - Used to create and retrieve data from the database very quickly

23. Case manipulation


1. CONCAT: Concatenates [joins] the first character value to the second character value; equivalent
to concatenation operator (||).
2. SUBSTR: Returns specific characters from character value starting at a specific character position
and going specified character positions long
3. INSTR: Returns the numeric position of a named string.
4. LENGTH: Returns the number of characters in the expression
5. LPAD: Pads the left side of

24. Use of alias command


SQL aliases are used to give a table, or a column in a table, a temporary name.

25. Diff between scalar and aggregate function


Scalar
SQL scalar functions return a single value, based on the input value. For example, if we have to
calculate the length of the string or want to convert letters in upper case or lower case then just we
have to pass the string as an input and scalar function will return the required value.

Aggregate
Aggregate functions are used to operates on data sets of a column of a table in SQL Database and
return a result.
26. Pattern matching operators
Like

27. What is use of distinct


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

28. What is substring


The SUBSTRING() function extracts some characters from a string.

SELECT SUBSTRING('SQL Tutorial', 1, 3) AS ExtractString;

29. Diff between sql and pl-sql

Basic In SQL you can execute a single In PL/SQL you can execute a block of code at a
query or a command at a time. time.

Full Structured Query Language Procedural Language, extension of SQL.


form

Purpose It is like a source of data that is to be It is language that creates an application that
displayed. display's the data acquired by SQL.

Writes In SQL you can write queries and In PL/SQL you can write block of code that has
command using DDL, DML procedures, functions, packages or variables, etc.
statements.

Use Using SQL, you can retrieve, modify, Using PL/SQL, you can create applications or
add, delete, or manipulate the data in server pages that display's the information obtained
the database. from SQL in a proper format.

Embed You can embed SQL statement in You can not embed PL/SQL in SQL
PL/SQL.

30. What are local and global variables

Local variable:
● A user declares the local variable.
● By default, a local variable starts with @.
● Every local variable scope has the restriction to the current batch or procedure within any
given session.

Global variable:

31. The system maintains the global variable. A user cannot declare them.
32. The global variable starts with @@
33. It stores session related information.

34. What is auto increment


Sometimes while creating a table we do not have unique identifier within the table hence we face
difficulty in choosing Primary Key. so as to resolve such an issue we’ve to manually provide
unique keys to every record but this is often also a tedious task .So we can use Auto Increment
feature that automatically generates a numerical Primary key value for every new record inserted.

35. What is stuff and replace function


STUFF: Using the stuff function we delete a substring of a certain length of a string and replace
it with a new string.

REPLACE: As the function name replace indicates, the replace function replaces all occurrences
of a specific string value with another string.

36. What is select into


The SELECT INTO statement copies data from one table into a new table.

37. How to fetch common records


Select * from student) Intersect (Select * from student1)

38. Any five dml,ddl commands


Ddl commands
39. CREATE – is used to create the database or its objects (like table, index, function, views, store
procedure and triggers).
40. DROP – is used to delete objects from the database.
41. ALTER-is used to alter the structure of the database.
42. TRUNCATE–is used to remove all records from a table, including all spaces allocated for the
records are removed.
43. COMMENT –is used to add comments to the data dictionary.
44. RENAME –is used to rename an object existing in the database.

Dml commands-

● INSERT – is used to insert data into a table.


● UPDATE – is used to update existing data within a table.
● DELETE – is used to delete records from a database table.

Dcl-

● GRANT-gives users access privileges to the database.


● REVOKE-withdraw user’s access privileges given by using the GRANT command.

Tcl-

● COMMIT– commits a Transaction.


● ROLLBACK– rollbacks a transaction in case of any error occurs.
● SAVEPOINT–sets a savepoint within a transaction.
● SET TRANSACTION–specify characteristics for the transaction.

45. What is diff primary key and unique constraints

Basic Used to serve as a unique identifier Uniquely determines a row


for each row in a table. which isn’t primary key.

NULL value acceptance Cannot accept NULL values. Can accepts NULL values.

Number of keys that can be Only one primary key More than one unique key
defined in the table

Index Creates clustered index Creates non-clustered index

46. Diff between function and stored procedure

A function has a return type and returns a value. A procedure does not have a return type. But it
returns values using the OUT parameters.
You cannot use a function with Data Manipulation You can use DML queries such as insert,
queries. Only Select queries are allowed in functions. update, select etc… with procedures.

A function does not allow output parameters A procedure allows both input and output
parameters.

You cannot manage transactions inside a function. You can manage transactions inside a
procedure.

You cannot call stored procedures from a function You can call a function from a stored
procedure.

You can call a function using a select statement. You cannot call a procedure using select
statements.

47. How to perform bulk insert

48. What is locking

49. What is colace


The COALESCE() function returns the first non-null value in a list.

50. Is the null value is 0 ?


a NULL means that there is no value, we're looking at a blank/empty cell, and 0 means the value
itself is 0.

51. What Temporary tables


There are RDBMS, which support temporary tables. Temporary Tables are a great feature that lets
you store and process intermediate results by using the same selection, update, and join
capabilities that you can use with typical SQL Server tables.

52. What are entities and relationships

53. Need of grouping function


The GROUP BY statement groups rows that have the same values into summary rows, like "find the
number of customers in each country".

The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(),
AVG()) to group the result-set by one or more columns.
54. Diff between views and table

1. A table is used to organize data in the form of Views are treated as a virtual/logical table
rows and columns and displayed them in a used to view or manipulate parts of the table.
structured format. It makes the stored information It is a database object that contains rows and
more understandable to the human. columns the same as real tables.

2. Table is a physical entity that means data is The view is a virtual entity, which means data
actually stored in the table. is not actually stored in the table.

3. It is used to store the data. It is used to extract data from the table.

4. It generates a fast result. The view generates a slow result because it


renders the information from the table every
time we query it.

5. It is an independent data object. It depends on the table. Therefore we cannot


create a view without using tables.

6. Table allows us to perform DML operations. The view will enable us to perform DML
operations.

7. It is not an easy task to replace the table directly It is an easy task to replace the view and
because of its physical storage. recreate it whenever needs.

8. It occupies space on the systems. It does not occupy space on the systems.

55. Diff between union and union all


UNION ALL keeps all of the records from each of the original data sets, UNION removes any
duplicate records. UNION first performs a sorting operation and eliminates of the records that are
duplicated across all columns before finally returning the combined data set.

You might also like