What is SQL?
SQL is Structured Query Language - used to store, manipulate and retrieve
data from RDBMS.
(It is not a database, it is a language used to interact with database)
We use SQL for CRUD Operations :
● CREATE - To create databases, tables, insert tuples in tables etc
● READ - To read data present in the database.
● UPDATE - Modify already inserted data.
● DELETE - Delete database, table or specific data point/tuple/row or
multiple rows.
*Note - SQL keywords are NOT case sensitive. Eg: select is the same as
SELECT in SQL.
SQL v/s MySQL
SQL is a language used to perform CRUD operations in Relational DB,while
MySQL is a RDBMS that uses SQL.
1. Data Definition Language (DDL)
Data Definition Language (DDL) is a subset of SQL (Structured Query
Language)
responsible for defining and managing the structure of databases and
their objects.
DDL commands enable you to create, modify, and delete database objects
like tables, indexes, constraints, and more. Key DDL Commands are:
● CREATE TABLE:
○ Used to create a new table in the database.
○ Specifies the table name, column names, data types, constraints, and
more.
○ Example:
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50),
salary DECIMAL(10, 2));
2. DATA MANIPULATION LANGUAGE
Data Manipulation Language (DML) in SQL encompasses commands that
manipulate data within a database. DML allows you to insert, update, and
delete records, ensuring the accuracy and currency of your data.
A) INSERT:
The INSERT statement adds new records to a table.
Syntax: INSERT INTO table_name (column1, column2, ...) VALUES (value1,
value2,
...);
Example: INSERT INTO employees (first_name, last_name, salary) VALUES
('John',
'Doe', 50000);
B)UPDATE:
The UPDATE statement modifies existing records in a table.
Syntax: UPDATE table_name SET column1 = value1, column2 = value2, ...
WHERE
condition;
Example: UPDATE employees SET salary = 55000 WHERE first_name =
'John';
C)DELETE:
The DELETE statement removes records from a table.
Syntax: DELETE FROM table_name WHERE condition;
Example: DELETE FROM employees WHERE last_name = 'Doe';
TASK-1 CREATE A TABLE PERSON IN UR DATABASE WITH FOLLOWING
FIELDS AND ASSIGN RESPECTIVE DATATYPE AND INSERT THE FOLLOWING
RECORDS.
TASK-2 : CREATE A TABLE EMPLOYEE WITH BELOW FIELDS AND
RESPECTIVE DATATYPES.INSERT THE BELOW RECORDS INTO THE TABLE
TASK3
TASK 4:
TASK 5: