In SQL, keywords are reserved words that have special meaning and are used to perform various tasks such as defining or manipulating data in a database. Here's a list of common SQL keywords and their functions:
Data Definition Language (DDL) Keywords:
- CREATE: Defines a new table, database, view, index, or other objects.
- ALTER: Modifies an existing database object (e.g., adding a column to a table).
- DROP: Deletes a database object (e.g., a table or view).
- TRUNCATE: Removes all records from a table, but does not delete the table structure.
- RENAME: Renames an object in the database (e.g., a table or column).
- COMMENT: Adds comments to database objects.
Data Manipulation Language (DML) Keywords:
- SELECT: Retrieves data from one or more tables.
- INSERT: Adds new rows of data into a table.
- UPDATE: Modifies existing data within a table.
- DELETE: Removes data from a table.
Data Control Language (DCL) Keywords:
- GRANT: Assigns permissions to users or roles.
- REVOKE: Removes permissions from users or roles.
Transaction Control Language (TCL) Keywords:
- COMMIT: Saves the current transaction to the database.
- ROLLBACK: Reverts the database to the last committed state.
- SAVEPOINT: Sets a point within a transaction to which you can later roll back.
- SET TRANSACTION: Configures properties of a transaction (e.g., isolation level).
Other Common SQL Keywords:
- WHERE: Filters records based on a specified condition.
- ORDER BY: Sorts the result set based on one or more columns.
- GROUP BY: Groups records based on specified columns for aggregate functions (e.g., COUNT, AVG).
- HAVING: Filters groups based on a condition (often used with
GROUP BY). - JOIN: Combines rows from two or more tables based on a related column.
- IN: Checks if a value matches any value in a list or subquery.
- BETWEEN: Filters records within a specified range.
- LIKE: Searches for a specified pattern in a column.
- AND/OR: Combines multiple conditions in a
WHEREclause. - NULL: Represents a missing or undefined value.
- DISTINCT: Removes duplicate records from the result set.
- AS: Renames a table or column for the duration of the query.
- EXISTS: Tests for the existence of records in a subquery.
These are just a few of the common SQL keywords. Each database management system (DBMS) may have additional keywords or slight variations in syntax, so it’s important to consult the documentation for your specific DBMS.
No comments:
Post a Comment