أسئلة القسم
تدرب على أسئلة المقابلات في هذا القسم. اكتب إجابتك، قم بتقييمها، أو اضغط على "عرض الإجابة" بعد التفكير.
What are types of variables in SQL? سهل
Types of Variables in SQL:
- Local variables: Declared using
DECLARE
inside a batch or stored procedure. - Global variables: Predefined system variables starting with
@@
, e.g.,@@ROWCOUNT
,@@VERSION
.
What are types of Functions? سهل
Types of Functions in SQL:
- Scalar Functions: Return a single value (e.g.,
LEN()
,GETDATE()
). - Aggregate Functions: Operate on a set of values and return one result (e.g.,
SUM()
,AVG()
). - Table-Valued Functions: Return a table (Inline or Multi-Statement).
What is constraint? سهل
A constraint is a rule applied to a column or table to enforce data integrity.
Types of Constraints:
PRIMARY KEY
FOREIGN KEY
UNIQUE
CHECK
DEFAULT
NOT NULL
What is Composite Key and Unique Key? سهل
- Composite Key: A key made of two or more columns to uniquely identify a row.
- Unique Key: Ensures uniqueness for a column (or set of columns), allows one
NULL
value.
What is the difference between Primary Key and Foreign Key? سهل
Primary Key | Foreign Key |
---|---|
Uniquely identifies a row. | Refers to primary key in another table. |
Only one allowed per table. | Multiple FKs allowed. |
No NULLs. | Can allow NULLs. |
What are Types of Joins? سهل
Types of Joins in SQL:
- INNER JOIN: Returns matching rows.
- LEFT JOIN: All rows from left table + matching from right.
- RIGHT JOIN: All rows from right table + matching from left.
- FULL OUTER JOIN: All rows, matched or unmatched.
- CROSS JOIN: Cartesian product.
- SELF JOIN: Join table with itself.
What is alias in SQL? سهل
An alias is a temporary name for a table or column.
Example:
SELECT e.Name AS EmployeeName FROM Employees e;
What is difference between Union and Union All? سهل
UNION | UNION ALL |
---|---|
Removes duplicates. | Keeps duplicates. |
Slightly slower. | Faster. |
What is different between Where and Having? سهل
- WHERE: Filters rows before grouping.
- HAVING: Filters groups/aggregates after grouping.