You are on page 1of 3

CREATE TABLE Employees (

EmployeeID INT PRIMARY KEY,


FirstName VARCHAR(50),
LastName VARCHAR(50),
Department VARCHAR(50)
);

-- Insert data into the table


INSERT INTO Employees (EmployeeID, FirstName, LastName, Department)
VALUES (1, 'John', 'Doe', 'IT'),
(2, 'Jane', 'Smith', 'HR');

-- Query data from the table


SELECT * FROM Employees;

-- Update a record
UPDATE Employees
SET Department = 'Finance'
WHERE EmployeeID = 2;

-- Delete a record
DELETE FROM Employees
WHERE EmployeeID = 1;

OUTPUT :-

After creating the table and inserting the

EmployeeID | FirstName | LastName | Department


------------------------------------------------
1 | John | Doe | IT
2 | Jane | Smith | HR

After updating Jane Smith's department to 'Finance':

EmployeeID | FirstName | LastName | Department


------------------------------------------------
1 | John | Doe | IT
2 | Jane | Smith | Finance

After deleting John Doe's record:

EmployeeID | FirstName | LastName | Department


------------------------------------------------
2 | Jane | Smith | Finance

===================================================================================
==========================================
SELECT: Retrieve data from one or more tables.
INSERT: Add new records into a table.
UPDATE: Modify existing records in a table.
DELETE: Remove records from a table.
CREATE: Create new tables, views, or other database objects.
ALTER: Modify existing database objects.
DROP: Delete tables, views, or other database objects.

-----------------------------------------------------------------------------------
-------------------------
SELECT: Retrieves data from one or more tables.
Example:
SELECT column1, column2 FROM table_name;

--------------------------------------------------------------------------------

INSERT: Adds new records into a table.


Example:
INSERT INTO table_name (column1, column2) VALUES (value1, value2);

---------------------------------------------------------------------------------

UPDATE: Modifies existing records in a table.


Example:
UPDATE table_name SET column1 = value1 WHERE condition;

---------------------------------------------------------------------------------

DELETE: Removes records from a table.


Example:
DELETE FROM table_name WHERE condition;

---------------------------------------------------------------------------------

CREATE: Creates new tables, views, indexes, or other database objects.


Example:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
...
);

----------------------------------------------------------------------------------

ALTER: Modifies existing database objects like tables.


Example:
ALTER TABLE table_name ADD column_name datatype;

-----------------------------------------------------------------------------------

DROP: Deletes tables, views, indexes, or other database objects.


Example:
DROP TABLE table_name;

-----------------------------------------------------------------------------------

JOIN: Combines records from two or more tables based on a related column between
them.
Example:
SELECT column1, column2 FROM table1 INNER JOIN table2 ON table1.column =
table2.column;

-----------------------------------------------------------------------------------
-

WHERE: Filters records based on specified conditions.


Example:
SELECT column1, column2 FROM table_name WHERE condition;
-----------------------------------------------------------------------------------
--

GROUP BY: Groups rows that have the same values into summary rows.
Example:
SELECT column1, COUNT(column2) FROM table_name GROUP BY column1;

-----------------------------------------------------------------------------------
---

ORDER BY: Sorts the result set in ascending or descending order.


Example:
SELECT column1, column2 FROM table_name ORDER BY column1 ASC;

-----------------------------------------------------------------------------------
--

HAVING: Filters groups specified in the GROUP BY clause.


Example:
SELECT column1, COUNT(column2) FROM table_name GROUP BY column1 HAVING
COUNT(column2) > 10;

-----------------------------------------------------------------------------------
---

DISTINCT: Returns unique values in a column or a combination of columns.


Example:
SELECT DISTINCT column1 FROM table_name;

-----------------------------------------------------------------------------------
----

AS: Renames a column or table with an alias.


Example:
SELECT column1 AS alias_name FROM table_name;

-----------------------------------------------------------------------------------
----
These are some of the fundamental keywords in SQL,
but there are many more depending on the specific functionality and
features supported by the SQL dialect of your chosen RDBMS (Relational Database
Management System).

You might also like