Looking for the SQL commands to effectively control your database?
Have you ever imagined how websites and apps handle their data? Well, the secret is in something called databases. They use a special language called SQL (Structured Query Language) to manage and organize all their data.
SQL acts as a foundation for relational database management systems (RDBMS). It offers a robust and consistent approach to engaging with databases.
Whether you are a database analyst, a software developer, or just starting your data journey, understanding SQL commands is essential for efficient data manipulation and retrieval.
In this blog, we will talk about 90+ SQL commands that will help you feel more comfortable when working with databases.
SQL Commands
| Number | Command | USe For |
|---|---|---|
| 1 | Select | Retrieve data from a database |
| 2 | Insert | Inserts new data into a database |
| 3 | UPDATE | Updates existing data in a database |
| 4 | DELETE | Deletes data from a database |
| 5 | CREATE DATABASE | Creates a new database |
| 6 | CREATE TABLE | Creates a new table in a database |
| 7 | ALTER TABLE | Modifies an existing table structure |
| 8 | DROP TABLE | Deletes a table from a database |
| 9 | TRUNCATE TABLE | Removes all records from a table |
| 10 | CREATE INDEX | Creates an index on a table |
| 11 | DROP INDEX | Deletes an index from a table |
| 12 | JOIN | Combines rows from two or more tables based on a related column |
| 13 | INNER JOIN | Returns rows when there is a match in both tables |
| 14 | LEFT JOIN | Returns all rows from the left table, and the matched rows from the right table |
| 15 | RIGHT JOIN | Returns all rows from the right table, and the matched rows from the left table |
| 16 | FULL JOIN | Returns rows when there is a match in one of the tables |
| 17 | UNION | Combines the results of two or more SELECT statements |
| 18 | UNION ALL | Combines the results of two or more SELECT statements, including duplicates |
| 19 | GROUP BY | Groups rows that have the same values into summary rows @code_learning |
| 20 | HAVING | Filters records based on a specified condition |
| 21 | ORDER BY | Sorts the result set in ascending or descending order |
| 22 | COUNT | Returns the number of rows that satisfy the condition |
| 23 | SUM | Calculates the sum of a set of values |
| 24 | AVG | Calculates the average of a set of values |
| 25 | MIN | Returns the smallest value in a set of values |
| 26 | MAX | Returns the largest value in a set of values |
| 27 | DISTINCT | Selects unique values from a column |
| 28 | WHERE | Filters records based on specified conditions |
| 29 | AND | Combines multiple conditions in a WHERE clause |
| 30 | OR | Specifies multiple alternative conditions in a WHERE clause |
| 31 | NOT | Negates a condition in a WHERE clause |
| 32 | BETWEEN | Selects values within a specified range |
| 33 | IN | Specifies multiple values for a column |
| 34 | LIKE | Selects rows that match a specified pattern |
| 35 | IS NULL | Checks for NULL values in a column |
| 36 | IS NOT NULL | Checks for non-NULL values in a column |
| 37 | EXISTS | Tests for the existence of any record in a subquery |
| 38 | CASE | Performs conditional logic in SQL statements |
| 39 | WHEN | Specifies conditions in a CASE statement |
| 40 | THEN | Specifies the result if a condition is true in a CASE statement |
| 41 | ELSE | Specifies the result if no condition is true in a CASE statement |
| 42 | END | Ends the CASE statement |
| 43 | PRIMARY KEY | Uniquely identifies each record in a table |
| 44 | FOREIGN KEY | Establishes a relationship between tables |
| 45 | CONSTRAINT | Enforces rules for data in a table |
| 46 | DEFAULT | Specifies a default value for a column |
| 47 | NOT NULL | Ensures that a column cannot contain NULL values |
| 48 | UNIQUE | Ensures that all values in a column are unique |
| 49 | CHECK | Enforces a condition on the values in a column |
| 50 | CASCADE | Automatically performs a specified action on related records |
| 51 | SET NULL | Sets the value of foreign key columns to NULL when a referenced record is deleted SET |
| 52 | DEFAULT | Sets the value of foreign key columns to their default value when a referenced record is deleted |
| 53 | NO ACTION | Specifies that no action should be taken on related records when a referenced record is deleted |
| 54 | RESTRICT | Restricts the deletion of a referenced record if there are related records |
| 55 | CASE WHEN | Conditional expression in SELECT statements |
| 56 | WITH | Defines a common table expression (CTE) |
| 57 | INTO | Specifies a target table for the result set of SELECT statement |
| 58 | TOP | Limits the number of rows returned by a query |
| 59 | LIMIT | Limits the number of rows returned by a query (used in some SQL dialects) |
| 60 | OFFSET | Specifies the number of rows to skip before starting to return rows |
| 61 | FETCH | Retrieves rows from a result set one at a time |
| 62 | ROW_NUMBER( ) | Assigns a unique sequential integer to each row in a result set |
| 63 | RANK( ) | Assigns a unique rank to each row in a result set, with gaps in the ranking sequence possible |
| 64 | DENSE_RANK( ) | Assigns a unique rank to each row in a result set, with no gaps in the ranking sequence |
| 65 | NTILE( ) | Divides the result set into a specified number of equally sized groups |
| 66 | LEAD( ) | Retrieves the value from the next row in a result set |
| 67 | LAG( ) | Retrieves the value from the previous row in a result set |
| 68 | PARTITION BY | Divides the result set into partitions to which the window function is applied separately |
| 69 | ORDER BY | Specifies the order of rows within each partition for window functions |
| 70 | ROWS | Specifies the window frame for window functions |
| 71 | RANGE | Specifies the window frame based on values rather than rows for window functions |
| 72 | CURRENT_TIMESTAMP | Returns the current date and time |
| 73 | CURRENT_DATE | Returns the current date |
| 74 | CURRENT_TIME | Returns the current time |
| 75 | DATEADD | Adds a specified time interval to a date |
| 76 | DATEDIFF | Calculate the difference between the two dates |
| 77 | DATEPART | Extracts a specific part of a date |
| 78 | GETDATE | Returns the current date and time (similar to CURRENT_TIMESTAMP) |
| 79 | GROUPING SETS | Specifies multiple groupings for aggregation |
| 80 | CUBE | Generates all possible combinations of grouping sets for aggregation |
| 81 | ROLLUP | Generates subtotal values for a hierarchy of values |
| 82 | INTERSECT | Returns the intersection of two result sets |
| 83 | EXCEPT | Returns the difference between two result sets |
| 84 | MERGE | Performs insert, update, or delete operations on a target table based on the results of a join with a source table |
| 85 | CROSS APPLY | Performs a correlated subquery against each row of the outer table |
| 86 | OUTER APPLY | Similar to CROSS APPLY, but also returns rows from the outer table that have no matching rows in the inner table |
| 87 | PIVOT | Rotates a table-valued expression by turning the unique values from one column into multiple columns in the output |
| 88 | UNPIVOT | Rotates a table-valued expression by turning multiple columns into unique rows in the output |
| 89 | COALESCE | Returns the first non-NULL expression in a list |
| 90 | NULLIF | Returns NULL if the two specified expressions are equal, otherwise returns the first expression |
| 91 | IIF | Returns one of two values based on a Boolean expression |
| 92 | CONCAT | Concatenates two or more strings |
| 93 | SUBSTRING | Extracts a substring from a string |
| 94 | CHARINDEX | Finds the position of a substring within a string |
| 95 | REPLACE | Replaces all occurrences of a specified substring within a string with another substring |
| 96 | LEN | Returns the length of a string |
| 97 | UPPER | Converts a string to uppercase |
| 98 | LOWER | Converts a string to lowercase |
| 99 | TRIM | Removes leading and trailing spaces from a string |
| 100 | ROUND | Rounds a numeric value to a specified number of decimal places |
Conclusion
SQL commands are the foundation of effective database management, allowing users to effortlessly engage with and control data. Whether you are retrieving information or modifying the structure of the tables, having strong SQL commands is vital for individuals involved in relational databases.
When you use these commands the right way, you can make the most out of your database and make sure your application runs really well.
Thanks for reading this blog. We hope this article provided helpful information regarding SQL commands.
Read More –





