Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views

SQL Notes

Uploaded by

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

SQL Notes

Uploaded by

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

1.What is normalization in sql?

Ans :- Normalization in SQL is the process of organizing data in a database to


reduce redundancy and inconsistent dependency.

2.How to insert a date in SQL?


Ans:- MySQL
INSERT INTO your_table (date_column) VALUES (CURDATE());

-- SQL Server
INSERT INTO your_table (date_column) VALUES (GETDATE());

3.What are aggregate and scaler function in SQL?


Ans :- These functions perform calculations on a group of values and return a
single result.
Example :- Count(),Sum(),Avg(),Min(),Max()
-->These functions return a single value based on the input value(s) and are used
to perform various operations on individual rows.
Example:- Now(),Round(),Length(),Concate(),Substring()

4.What does a window function do in SQL?


Ans :- A window function in SQL performs a calculation across a set of table rows
that are somehow related to the current row.

5.Difference between rank,dense-rank and row number in SQL?


Ans :- Rank :- This function ranks the rows within a partition based on a specified
order. When there are no ties, rank() behaves similarly to row_number().
Example :- SELECT
name,
rank() OVER (PARTITION BY department ORDER BY salary DESC) AS employee_rank
FROM
employees
ORDER BY
department, employee_rank;
Dense-Rank :- This function also ranks the rows within a partition based on a
specified order. Like rank(), dense_rank() assigns the same rank to all tied rows.
Example :- SELECT
name,
dense_rank() OVER (PARTITION BY department ORDER BY salary DESC) AS employee_rank
FROM
employees
ORDER BY
department, employee_rank;
Row Number :- This function assigns a unique, sequential number to each row within
a partition. It does not consider any ranking or ties. When there are no ties,
row_number() behaves similarly to rank() and dense_rank().
Example :- SELECT
name,
row_number() OVER (PARTITION BY department ORDER BY salary DESC) AS row_num
FROM
employees
ORDER BY
department, row_num;

6.What are Clustered and Non-Clustered index in SQL?


Ans :- Clustered index :- Clustered indexes define the physical order in which data
is stored in a table. Here are some key points about clustered indexes:
-->There can be only one clustered index per table.
-->The table data is sorted based on the clustered index key.
-->SQL Server automatically creates a clustered index for the primary key column(s)
unless a clustered index already exists.
Example:
CREATE TABLE Student (
Roll_No INT PRIMARY KEY,
Name VARCHAR(50),
Gender VARCHAR(10),
Mob_No VARCHAR(20)
);
-->Example of a clustered index creation
CREATE CLUSTERED INDEX CIX_Roll_No ON Student (Roll_No);

Non-Clustered index :- Non-Clustered indexes, on the other hand, are stored


separately from the data and contain a pointer to the actual data row. Some key
points about non-clustered indexes:
-->A table can have multiple non-clustered indexes.
-->Non-clustered indexes can use columns from one or more tables in a query.
-->They can improve the performance of queries that search for specific values in a
column.
Example:
-- Example of a non-clustered index creation
CREATE NONCLUSTERED INDEX NIX_Name ON Student (Name);

7.What is SQL?
Ans :- Structured Query Language (SQL) is a programming language used to manage,
store, update, remove, search, and retrieve information from a relational database.
--->Manage :- using transact-SQL
--->Relational Database :-A relational database is a type of database that stores
and provides access to data points that are related to one another.

8.Advantages and disadvantages in SQL?


Ans :- Advantages :- Faster query processing,no coding skills,standardized
language,portable,multiple data views - scalability,security,data itegrity,backup
and recovery,data consistency

Disadvantages :- Complex interface,cost,partial control,limited flexibilty,lack of


real time analytics,limited query performance,complexity

9.What is database?And how to create a database in SQL?


ANS :-A database is an organized collection of data used to store and retrieve data
efficiently.
-->The CREATE DATABASE statement is used to create a new database in SQL.

10.What is DBMS?
Ans :- A database management system (DBMS) is a computerized solution that helps
store information in a way that is easy to read, edit, delete, and scale.

11.What are tables and fields?


Ans :-

12.What are constraints in SQL?


Ans :-Constraints in SQL are rules applied to data columns or entire tables to
limit the type of data that can be stored within them.
Example :- CREATE TABLE Employees (
id INT NOT NULL,
name VARCHAR(50) NOT NULL,
salary DECIMAL(10,2)
);

13.What is a TRIGGER in SQL?


Ans :- A trigger in SQL is a special type of stored procedure that automatically
executes in response to a specific event or action on a table, such as inserting,
updating, or deleting data.
Example :- DML TRIGGER :- CREATE TRIGGER Employee_Insert_Audit
ON Employees
AFTER INSERT
AS
BEGIN
INSERT INTO Employee_Audit (EmployeeID, LogTime, Action)
SELECT i.EmployeeID, GETDATE(), 'Insert'
FROM inserted i;
END;

14.Hi [Recruiter's Name],

I hope this message finds you well. I came across your profile and was impressed by
your extensive experience in [mention relevant area]. I noticed that [mention
something specific from their profile or recent activity].

I'm reaching out to express my interest in the [Job Title] position at [Company
Name]. With [X years/months] of experience in [mention relevant industry or field],
I'm confident in my ability to contribute effectively to [Company Name]. I'm
particularly excited about the opportunity to [mention something specific about the
role or company].

I've attached my resume for your reference, and I would welcome the opportunity to
connect and discuss how my skills and experience align with the needs of your team.
Would you be open to connecting on LinkedIn?

Thank you for considering my application. I look forward to the possibility of


discussing this opportunity further.

Best regards,
[Your Name]

You might also like