SQL Tutorial 6: Data Manipulation Language
SQL Tutorial 6: Data Manipulation Language
Data Manipulation Language (DML) is a one of the Subset of SQL, others are,
i) Data Definition Language
ii) Data Control Language etc…
Database Engine is required to practice/execute SQL Commands…
Database Engine either Oracle or MS SQL Server or mySQL etc…
I installed MS SQL Server Express Edition, It is free Software for Small scale
organizations, you can use any other Database Engine also, anyhow Most of the
SQL Commands are common for all RDBMS….
Data Manipulation Language commands are used to store, modify, retrieve, and delete data from database tables. In this category we have Select, Insert, Update, Delete Commands….
————————–
Important Data manipulation language Commands are,
1) SELECT – Retrieves data from a table
2) INSERT – Inserts data into a table
3) UPDATE – Updates existing data into a table
4) DELETE – Deletes all records from a table
In Order to practice/use SQL DML Commands, first I create a Database, a Table and these are SQL DDL Operations (we have to use DDL Commands)…
Next Insert records in to the table, It is DML Operation…
Example:
—Create a Database, table, and insert records…
Create database gcreddy;
Use gcreddy;
Create table abcd(
Id int,
Name varchar (40),
City varchar (30),
);
Insert Into abcd
(Id, Name, City)
values (1, ‘G C Reddy’, ‘Hyderabad’);
Insert Into abcd
(Id, Name, City)
values (2, ‘Mahith’, ‘Nellore’);
————————–
Data Manipulation Commands,
1) Select: The SELECT Statement is used to select data from a database. The result
is stored in a result table, called the result-set.
The SELECT command is the most commonly used command in SQL. It allows database
users to retrieve the specific information they desire from an operational database.
/* Select Syntax
Select colomn1, column2, …
From Table_Name;
Select * From Table_Name; */
Select Id, Name From abcd;
Select * From abcd;
————————–
2) Insert: The INSERT INTO Statement is used to insert new records in a table. We
can insert data to a table in two ways,
Syntax
INSERT INTO table_name (column1, column2 …)
VALUES (value1, value2, …);
Example:
Insert Into abcd (Id, Name, City)
values(4, ‘Vijaya’, ‘Kavali’);
—————–
Insert Data Only in Specified Columns
Insert Into abcd (Name)
values (‘Cinnu’);
Note: If you insert specified column only then remaining columns are Null…
————————–
3) Update: The UPDATE statement is used to update existing records in a table.
Syntax:
UPDATE table_name
SET column1=value, column2=value2,…
WHERE some_column=some_value
Example:
Update abcd
Set Name = ‘Venkat’, City = ‘Mumbai’
Where Id = 1;
————————–
4) Delete: The SQL DELETE Query is used to delete the existing records from a table.
You can use WHERE clause with DELETE query to delete selected rows,
otherwise all the records would be deleted.
Syntax: DELETE FROM table_name [WHERE condition];
Example:
Delete From abcd
Where Id = 4;
Delete From abcd;
————————————————–
SQL Step by Step Tutorials
https://www.gcreddy.com/2016/08/sql-tutorials.html
SQL Tutorial 1: Introduction to SQL
https://www.gcreddy.com/2016/07/introduction-to-sql.html
SQL Tutorial 2: SQL Overview
https://www.gcreddy.com/2016/08/sql-overview.html
SQL Tutorial 3: SQL Environment Setup
https://www.gcreddy.com/2016/09/sql-environment-setup.html
SQL Tutorial 4: Database Fundamentals and SQL Language Elements
https://www.gcreddy.com/2016/11/database-fundamentals-and-sql-language.html
SQL Tutorial 5: Data Definition Language
https://www.gcreddy.com/2016/11/sql-data-definition-language.html
SQL Tutorial 6: Data Manipulation Language
https://www.gcreddy.com/2017/06/sql-tutorial-6-data-manipulation.html
SQL Tutorial 7: SQL Operators
https://www.gcreddy.com/2017/06/sql-operators.html
SQL Tutorial 8: The Select Query
https://youtu.be/kid__0MNRps
SQL Tutorial 9: SQL Joins
https://youtu.be/K6U_WtYb-xQ
SQL Tutorial 10: SQL Functions
https://youtu.be/kgNnLWRZOiI
SQL Tutorial 11: SQL Comments
https://youtu.be/fg11vHRSsk0
SQL Tutorial 12: SQL Date Functions
https://youtu.be/EcanQwCjdWQ
Top 10 Database Management Systems
https://youtu.be/9R8xVrMgOb8
SQL vs. NoSQL Databases
https://youtu.be/1rX4yTqxdfQ
SQL Interview Questions and Answers
https://www.gcreddy.com/2013/01/sql-interview-questions.html
————————–