SQL interview Questions Flashcards

1
Q

What is the difference between delete and truncate statements?

A

DELETE : Deletes a ROW within a table
DML
You CAN bring back data
SLOWER

TRUNCATE: Deletes ALL ROWS from table
DDL
You CANNOT bring back data
FASTER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the different subsets of SQL

A

DDL, DML, DCL, TCL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What do you mean by DBMS (Database Management Systems)? What are the different types?

A
  • A DBMS is basically a data keeping system. The data can stored in these DBMSs can be modified, retrieved, & deleted.
  • There are four types of DBMSs
  • Hierarchal
  • Object Oriented
  • Network
  • Relational
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What do you mean by a table and field in SQL?

A

Table: A collection of data that is organized in BOTH rows & columns

Field: refers to the number of columns within a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are JOINS in SQL?

A

A Join clause is used to combine rows from two or more tables based on a related column between them.

Four types of Joins:
* Inner Join
* Full Join
* Left Join
* Right Join

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between CHAR & VARCHAR in SQL?

A

CHAR = fixed length (only 10 characters)

VARCHAR = variable length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a Primary Key?

A

It is usually the unique identifier within a relational database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are Constraints?

A

Constraints are usually used to specify the limits of the data

5 Constraints are:

  • Not Null
  • Unique
  • Check
  • Default
  • Index
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between SQL & MySQL?

A

SQL is the standard language and is also the core of relational database while MySQL is open source and provides multi-user access

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a Unique Key?

A

It’s the set of field or columns that helps us uniquely identify records.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a foreign key?

A

Foreign key is a constraint that links a column to another column from another table through the primary key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What do you mean by data integrity?

A

Data integrity refers to the accuracy and consistency of data stored in a database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between clustered & non-clustered index in SQL?

A

Clustered index is much faster & alters the way records are stored. You can only have ONE clustered index.

Non - clustered is much slower & does not alter the way data is stored. You can have MANY non-clustered indexes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Write a SQL query to display the current date:

A

Select GetDate ();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What do you mean by denormalization?

A

Denormalization is a technique used to access data from higher to lower forms of a database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly