SQL Statement Types
SQL statements can be defined into three major types: Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL). SQL language is relatively easy to learn and has fewer than 100 statements. The way different types of the SQL statements manipulate or control the data is what sets each apart. The three main categories can be broken down as follows:
- Data Definition Language – These types of statements create something in the database, like a table, index, or other properties of the actual database.
- ALTER TABLE – modifies a table’s definitions (ALTER TABLE table_name)
- DROP TABLE – Deletes a table and all of the data permanently (DROP TABLE table_name;)
- Be very careful using this and ensure backups are created first. The table will permanently deleted along with all of the data.
- Data Manipulation Language – These are used to manipulate the data, as the name implies, and lets users add, delete, update or retrieve data as needed.
- FROM – Tells the table the data should be pulled from.
- INSERT – Insert rows into a table
- DELETE – Can delete just one row from a table
- Data Control Language – These are used to control who has access to certain parts of the database.
- ROLLBACK – Brings data back to its original values
- GRANT – Givers users permission to access data from a table or object
Geeks4Geeks provided a nice chart that was used to illustrate the different statement types. While they provide extra examples of ones not included in this week’s discussion posting, the flow chart was still handy in knowing the differences between the different SQL statements. Learning about the SQL statements is very interesting because it is very straight forward. All of the commands are very direct and manipulating the data or tables comes relatively easy.
Comments
Post a Comment