Listen to this Post
SQL (Structured Query Language) is the foundation of database operations. Below is a comprehensive list of essential SQL keywords along with their functionalities:
✅ ADD: Used to add a new column to a table or to add constraints to a table.
✅ ALL: Used in SELECT statements to return all records; also used with aggregate functions to include all values.
✅ ALTER: Used to modify the structure of an existing database object, such as a table.
✅ AND: A logical operator used to combine multiple conditions in a WHERE clause.
✅ ANY: Used to compare a value to any value in a list or subquery.
✅ AS: Used to assign an alias to a table or column for easier reference.
✅ ASC: Specifies ascending order in an ORDER BY clause.
✅ CASE: A conditional expression that returns different values based on specified conditions.
✅ LIKE: Used in a WHERE clause to search for a specified pattern in a column.
✅ DESC: Specifies descending order in an ORDER BY clause.
✅ DROP: Used to delete a database object, such as a table or column.
✅ CHECK: A constraint that ensures a value meets a specific condition.
✅ EXEC: Executes a stored procedure.
✅ LIMIT: Constrains the number of records returned by a query (used primarily in MySQL).
✅ NOT: A logical operator used to negate a condition.
✅ OR: A logical operator used to combine multiple conditions in a WHERE clause.
✅ SET: Used to specify a value for a variable or to assign values to a column in an UPDATE statement.
✅ IN: Used to specify multiple possible values for a column in a WHERE clause.
✅ TOP: Specifies the number of records to return (used primarily in SQL Server).
✅ JOIN: Combines rows from two or more tables based on a related column.
✅ TABLE: Refers to a database table; used in various commands such as CREATE TABLE.
✅ FROM: Specifies the table from which to select or delete data.
✅ INDEX: A database object that improves the speed of data retrieval operations.
✅ UNION: Combines the result sets of two or more SELECT statements.
✅ EXISTS: Tests for the existence of any record in a subquery.
✅ COLUMN: Refers to a field in a table; used in various commands.
✅ SELECT: Retrieves data from one or more tables.
✅ BETWEEN: Used to filter the result set within a certain range.
✅ HAVING: Filters records after aggregation, used with GROUP BY.
✅ DATABASE: Refers to a collection of related data organized for easy access.
✅ CREATE: Used to create a new database object, such as a table or index.
✅ DELETE: Removes existing records from a table.
✅ UNIQUE: A constraint that ensures all values in a column are distinct.
✅ DEFAULT: Specifies a default value for a column when no value is provided.
✅ DISTINCT: Removes duplicate records from the result set of a SELECT statement.
You Should Know:
Practical SQL Commands & Examples
Basic SQL Queries
-- Selecting all records from a table SELECT FROM employees; -- Filtering data with WHERE SELECT name, salary FROM employees WHERE salary > 50000; -- Sorting results with ORDER BY SELECT FROM products ORDER BY price DESC;
Table Manipulation
-- Creating a new table CREATE TABLE users ( id INT PRIMARY KEY, username VARCHAR(50) UNIQUE, email VARCHAR(100) NOT NULL ); -- Adding a new column ALTER TABLE users ADD COLUMN age INT; -- Deleting a table DROP TABLE temp_data;
Joins & Subqueries
-- INNER JOIN example SELECT orders.order_id, customers.customer_name FROM orders INNER JOIN customers ON orders.customer_id = customers.id; -- Subquery with EXISTS SELECT name FROM employees WHERE EXISTS (SELECT 1 FROM departments WHERE employees.dept_id = departments.id);
Aggregation & Grouping
-- Using GROUP BY and HAVING SELECT department, AVG(salary) as avg_salary FROM employees GROUP BY department HAVING AVG(salary) > 60000;
Indexing for Performance
-- Creating an index CREATE INDEX idx_employee_name ON employees(name); -- Dropping an index DROP INDEX idx_employee_name;
Database Administration (Linux/Windows)
- Backing up a SQL Database (Linux/Mac):
mysqldump -u username -p database_name > backup.sql
- Restoring a Database:
mysql -u username -p database_name < backup.sql
- Checking Running Queries (PostgreSQL):
SELECT FROM pg_stat_activity;
What Undercode Say
SQL remains a fundamental skill for database management, cybersecurity (SQL injection prevention), and backend development. Mastering these keywords and commands ensures efficient data manipulation. For security, always use parameterized queries to prevent SQL injection.
Expected Output:
A structured guide to SQL keywords with practical examples for database operations.
Relevant URLs:
References:
Reported By: Sina Riyahi – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅