SQL Tutorial

SQL Tutorial SQL Introduction SQL Syntax SQL Data Types SQL OPERATORS SQL COMMANDS SQL Queries

SQL Database

SQL Create Database SQL DROP Database SQL SELECT Database

SQL Table

SQL TABLE SQL CREATE TABLE SQL COPY TABLE SQL ALTER TABLE SQL DELETE SQL TRUNCATE TABLE SQL DROP TABLE SQL UPDATE TABLE SQL INSERT TABLE

SQL SELECT

SQL SELECT Statement SQL SELECT WHERE Clause SQL SELECT IN Operator SQL BETWEEN Operator SQL SELECT BETWEEN Operator SQL SELECT AND Operator SQL SELECT OR Operator SQL SELECT LIKE Operator SQL SELECT DISTINCT SQL SELECT SUM SQL SELECT MAX SQL SELECT MIN SQL SELECT AVG

SQL Clause

SQL WHERE Clause SQL GROUP BY CLAUSE SQL ORDER BY Clause SQL HAVING Clause

SQL INSERT

SQL INSERT Statement SQL INSERT INTO Statement SQL INSERT INTO SELECT

SQL JOIN

SQL JOIN SQL Inner Join SQL Left Join SQL Right Join SQL Full Join SQL CROSS Join

SQL OPERATOR

SQL Comparison SQL LOGICAL Operator SQL Cast Operator SQL Arithmetic

Difference

SQL vs NOSQL WHERE vs HAVING DELETE vs DROP GROUP BY vs ORDER BY DROP vs TRUNCATE SQL IN vs SQL EXISTS

MISC

SQL SubQuery SQL CASE Commit and Rollback in SQL Pattern Matching in SQL DDL Commands in SQL DML Commands in SQL Types of SQL Commands SQL COUNT SQL Primary Key SQL FOREIGN KEY SET Operators in SQL Check Constraint in SQL SQL EXCEPT SQL VIEW SQL WHERE Statement SQL CRUD Operation Where Condition in SQL TCL Commands in SQL Types of SQL JOINS SQL Nth Highest Salary SQL NOT OPERATOR SQL UNION ALL SQL INTERSECT SQL Data Definition Language SQL Data Manipulation Language SQL Data Control Language SQL CONSTRAINTS SQL Aggregate Operators SQL KEYS Codd’s Rules in SQL What is SQL Injection? Trigger In SQL SQL WHERE Multiple Conditions Truncate function in SQL SQL Formatter WEB SQL SQL Auto Increment Save Point in SQL space() function in SQL SQL Aggregate Functions SQL Topological Sorting SQL Injection SQL Cloning Tables SQL Aliases SQL Handling Duplicate

How To

How to use the BETWEEN operator in SQL How To Use INNER JOIN In SQL How to use LIKE in SQL How to use HAVING Clause in SQL How to use GROUP BY Clause in SQL How To Remove Duplicates In SQL How To Delete A Row In SQL How to add column in table in SQL ? How to drop a column in SQL? How to create a database in SQL? How to use COUNT in SQL? How to Create Temporary Table in SQL? How to Add Foreign Key in SQL? How to Add Comments in SQL? How To Use Group By Clause In SQL How To Use Having Clause In SQL How To Delete Column In Table How To Compare Date In SQL

SQL Data Manipulation Language

Data Manipulation Language manipulates/make changes in data present in a table.

It only affects data/records of table, not on the schema/structure of table.

INSERT, UPDATE, DELETE are the commands of DML.

INSERT: Stores data in a table or creates new records by inserting values.
UPDATE: It modifies the record in a table.
DELETE: Deletes on or more records from table.
Syntax:
  1. INSERT INTO table_name VALUES ( value1,value2,….);
  2. INSERT INTO table_name (column 1,column 2, column 3) VALUES (value1, value2,value3);

Example:

INSERT INTO STUDENT VALUES (0001,'ARUN','CS','FIRST');
INSERT INTO STUDENT (classyear, student_name,student_dept,student_id) VALUES ('FIRST','VRUN','CS',0002);

Here, user can change the sequence of columns while inserting values in table. We can increase or decrease number of columns.

Syntax:

DELETE FROM Table_name [WHERE Condition];

Example:

Delete From Student Where Student_id=06;

Here, Single row is deleted as per where condition.

Delete From Student Where Student_name=’ARYA’;

Multiple rows deleted, as three rows were present with the same name ARYA. Here, where condition decides how many records to delete.

Delete From Student;

In the above query, where condition is not specified so, all records are deleted from STUDENT table. If user want to delete single or multiple records then where condition is required. Delete query without where condition deletes all records from table.

Syntax:

UPDATE Table_name set column_name = value [Where condition];

Example:

update student set student_dept='ele' where student_name='GITA';
UPDATE Student SET classyear='FINAL' Where student_id=9;

By using UPDATE command, user can update single value or multiple values in the table.

To change single value/to change specific value, ‘Where’ condition is required.

UPDATE without where condition changes complete column values in the table.

UPDATE STUDENT SET student_dept='EXTC';



ADVERTISEMENT
ADVERTISEMENT