SQL Commands with Syntax and Examples
SQL Commands:
SQL commands are instructions that is used to communicate with the database. It is also used to perform specific tasks, functions, and queries of data. It can perform various tasks like creating a table, adding data to tables, dropping the table, modifying the table, set permission for users.
SQL Commands with Syntax:
INSERT OPERATION:
INSERT command is used to insert data into the row of a table. After creating the tables, namely EMPLOYEE and DEPARTMENT, we shall insert data values into them using SQL command. It has the following syntax:
INSERT INTO <table-name> VALUES(<value>, <value>, ...);
SELECT Command:
SELECT command is used to retrieve the data from a table. This command also provides query capability. SELECT command is the same as the projection operation of relational algebra. It has the following syntax:
SELECT * FROM <table-name>;
UPDATE OPERATION:
UPDATE is SQL verb that changes or modifies the data values in a table. It has the following syntax:
UPDATE <table-name> SET <column-name = new value> [WHERE <condition>];
DELETE OPERATION:
You can remove rows from a table with the command DELETE. This command removes specific rows meeting the condition and not the individual field values. It has the following syntax:
UPDATE FROM <table-name> WHERE <condition>;
To remove all the contents of a table, you would enter the following statement:
DELETE FROM <table-name>;