SQL (Structured Query Language) is a standardized language used to manage and manipulate data in relational databases, handling tasks such as querying, updating, and organizing data.
Â
A relational database organizes data into structured tables that are related through shared data values. This approach enhances data integrity and allows complex queries.
Â
A primary key uniquely identifies each record in a table and ensures each entry has a distinct, non-null identifier, enforcing data integrity.
Â
A foreign key is a field in one table that creates a relationship with the primary key of another table, linking related data across tables.
Â
A join combines rows from multiple tables based on a related column, allowing for complex data retrieval across relational tables.
Â
An inner join returns rows with matching values in both tables, showing only relevant, intersecting data.
Â
An outer join includes matching rows from both tables plus any non-matching rows, filling gaps with NULL values for missing data.
Â
A left join returns all rows from the left table and matching rows from the right table, with NULLs for unmatched rows on the right.
Â
A right join returns all rows from the right table and matching rows from the left table, with NULLs for unmatched rows on the left.
Â
A cross join generates all possible row combinations from both tables, producing a Cartesian product.
Â
A subquery is a query within another query, often used to supply values for conditions or calculations in the main query.
Â
A correlated subquery references data from the outer query and runs once per row of the outer query, useful for complex comparisons.
Â
A self join joins a table to itself to find relationships within the same data set, often useful for hierarchical or comparative data.
Â
A union combines results of multiple SELECT queries into a single result, removing duplicate rows by default.
Â
An alias provides a temporary name to a column or table, enhancing readability and simplifying query syntax.
Â
A constraint defines rules for data values in a table, such as uniqueness, non-null values, or foreign key relationships.
Â
The NOT NULL constraint ensures that a column must contain a value, preventing NULL entries.
Â
A UNIQUE constraint ensures all values in a column are distinct, avoiding duplicate data entries.
Â
A PRIMARY KEY constraint uniquely identifies each record and combines NOT NULL and UNIQUE constraints for data integrity.
Â
A FOREIGN KEY constraint links tables by creating a relationship between two columns, enforcing referential integrity.
Â
A CHECK constraint enforces a condition on column values, ensuring they meet specific criteria.
Â
A DEFAULT constraint sets a default value for a column if no value is provided when a record is inserted.
Â
An index improves query performance by enabling faster data retrieval through a structured reference to table rows.
Â
A clustered index physically orders the table rows to match the index, speeding up queries that retrieve ordered data.
Â
A non-clustered index creates a separate lookup structure with pointers to the data rows, allowing multiple indexes per table.
Â
A unique index ensures that indexed column values are unique, similar to a UNIQUE constraint, and speeds up queries on those columns.
Â
A full-text index allows fast text searches on large columns, useful for searching within documents or descriptions.
Â
A view is a virtual table created by a query, which combines or filters data from one or more tables without storing it permanently.
Â
A stored procedure is a set of SQL statements saved and executed as a unit, allowing for reusability and complex operations.
Â
A trigger automatically executes a stored procedure in response to events like INSERT, UPDATE, or DELETE actions on a table.
Â
A transaction is a sequence of SQL statements that execute as a single unit, ensuring either full completion or none if an error occurs.
Â
A rollback undoes changes made by a transaction, restoring data to its state before the transaction began.
Â
A commit permanently saves changes made by a transaction to the database.
Â
A savepoint marks a specific point in a transaction, allowing partial rollback to that point instead of rolling back the whole transaction.
Â
A cursor retrieves and processes each row in a result set one by one, often used in stored procedures for row-by-row operations.
Â
Dynamic SQL constructs and executes SQL statements at runtime, providing flexibility for dynamic query building.
Â
A data type specifies the kind of data a column can hold, such as integers, strings, dates, or binary data.
Â
String data types, like CHAR, VARCHAR, and TEXT, are used to store text-based data in columns.
Â
Numeric data types store numerical values, including integer (INT), floating-point (FLOAT, DOUBLE), and decimal (DECIMAL) types.
Â
Date and time data types, like DATE, TIME, and TIMESTAMP, are used to store date and time values.
Â
Binary data types, like BLOB, are used to store binary data such as images, multimedia, or files.
Â
A NULL value represents missing or undefined data in a column.
Â
The GROUP BY clause groups rows by specified columns and is often used with aggregate functions (like COUNT or SUM) to summarize data.
Â
The HAVING clause filters groups created by GROUP BY based on aggregate function results, allowing conditions to be applied to groups.
Â
DISTINCT returns only unique rows, removing duplicates in a result set.
Â
LIMIT restricts the number of rows returned by a query, often used for pagination or sampling data.
Â
OFFSET skips a specified number of rows before returning results, often paired with LIMIT for pagination.
Â
UNION combines results from multiple queries into a single set, removing duplicates by default.