08 Create Update Delete, Insert Queries
08 Create Update Delete, Insert Queries
Muhammad Qasim
SQL Commands
These SQL commands are mainly categorized into four categories as:
DDL – Data Definition Language
◦ CREATE – is used to create the database or its objects (like table, index,
function, views, store procedure and triggers).
◦ DROP – is used to delete objects from the database.
◦ ALTER-is used to alter the structure of the database.
DQL – Data Query Language
◦ SELECT – is used to retrieve data from the a database.
DML – Data Manipulation Language
◦ INSERT – is used to insert data into a table.
◦ UPDATE – is used to update existing data within a table.
◦ DELETE – is used to delete records from a database table.
DCL – Data Control Language
◦ GRANT-gives user’s access privileges to database.
◦ REVOKE-withdraw user’s access privileges given by using the GRANT
command.
Create
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
UPDATE Customers
SET ContactName = 'Alfred Schmidt', City= 'Frankfurt'
WHERE CustomerID = 1;
Delete
DELETE FROM table_name WHERE condition;