SQL commands are a set of instructions that are used to interact with the database like Sql Server, MySql, Oracle etc. SQL commands are responsible to create and to do all the manipulation on the database. These are also responsible to give/take out access rights on a particular database
We have different sql commands for different-different purpose. We can grouped Sql Commands into five major categories depending on their functionality.
These SQL commands are used to create, modify, and drop the structure of database objects like table, view, procedure, indexes etc. In this category we have CREATE, ALTER, DROP and TRUNCATE commands.
Only with DDL commands we need to write keyword (like table, procedure, view, index, function) with the syntax of command.
These commands are used to create/modify the structure of the database object.
CREATE TABLE TABLE_NAME ( COL1 VARCHAR(10), COL2 VARCHAR(20), ); --Here "TABLE" is a keyword that is used to create table "TABLE_NAME" CREATE VIEW VIEW_NAME AS BEGIN SELECT * FROM EMP_TABLE END --Here "VIEW" is a keyword that is used to create VIEW "VIEW_NAME"
These SQL commands are used to store, modify, and delete data from database tables. In this category we have INSERT, UPDATE, and DELETE commands.
These SQL commands are used to fetch/retrieve data from database tables. In this category we have only SEELCT command.
These SQL commands are used to manage changes that affect the database. Basically we use these commands with in transaction or to make a stable point during changes in database at which we can rollback the database state if required. In this category we have COMMIT, ROLLBACK and SAVEPOINT.
These SQL commands are used to provide security to database objects. In this category we have GRANT and REVOKE commands.
Grant Command : This command is used to give permission to specific users on specific database objects like table, view etc.
Revoke Command : This command is used to take out permission from specific users on specific database objects like table, view etc.