Data Manipulation Language (DML)

DATA MANIPULATION LANGUAGE (DML)

SELECT:-

SELECT statements or commands are used to retrieve or select data from the table.

Syntax: 1

SELECT * from Table_name;

Example:

SELECT * from new_books;

Purpose:-

This statement used to select all columns from the specified table.

Syntax:2

SELECT column_name_1,column_name_2,....column_name_n from Table_name;

Purpose:-

This statement used to select particular columns from the specified table.

Example:

SELECT book_no ,book_name, author_id , price from new_books;

INSERT:-

The INSERT command is used for inserting one or more rows into a database table with specified table column values.

INTO is the keyword for the INSERT statement.

Syntax:

INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);

Example:

INSERT INTO table_name (book_no,book_name, author_id, ...) VALUES (1234, 'The Sql concepts' ,67895, ...);

UPDATE:-

The UPDATE statement is used to modify the existing records in a table.

SET is the keyword for the UPDATE statement.

Syntax:

UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;

Example:

UPDATE new_books SET book_no = 1235, book_name = 'The SQl Applications and Its uses' WHERE author_id=67895;

DELETE:-

The DELETE statement removes one or more records from a table.

Syntax:

DELETE FROM table_name WHERE condition;

Example:

DELETE FROM new_books WHERE author_id=67895;

 

Share:

Data Definition Language (DDL)

Data Definition Language (DDL)                                                

CREATE:

Syntax:-

CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype, .... );

Example:- 

CREATE TABLE book( book_no number, book_name varchar2(20), author_id varchar2(20), price number;

ALTER:-

ADD Columns:

Syntax:-

ALTER TABLE table_name ADD column_name datatype;

Example:-

ALTER TABLE book( ADD QUANTITY number);

Modify Columns:

Syntax:-

ALTER TABLE table_name MODIFY COLUMN column_name datatype;

Example:-

ALTER TABLE book MODIFY COLUMN author_id number;

Rename using alter statement:-

Syntax:-

ALTER TABLE table_name
RENAME TO new_table_name;

Example:-

ALTER TABLE book RENAME to books;

DROP:

Syntax:-

DROP TABLE table_name;

Example:-

DROP TABLE book;

Purpose:-  DROP is used to delete just a table. The DROP statement destroys objects like an existing database, table, index, or view.

TRUNCATE:

Syntax:-

TRUNCATE TABLE table_name;

Example:-

TRUNCATE TABLE book;

Purpose:-     Truncate used to delete all records from the database.

RENAME:-

Syntax:-

RENAME old_table _name To new_table_name;

Example:-

RENAME book to new_books;

 

 

 

Share:

SQL Introduction

SQL Introduction

What is SQL?

  • SQL stands for Structured Query Language. SQL is used to communicate with a database. It is the standard language for relational database management systems.
  • Some common relational database management systems that use SQL are Oracle, Sybase, Microsoft SQL Server and Access.

Some of the main purpose of using Oracle SQL:

1. SQL is used to retrieve data from the database

2. Update data on the database

Standard Commands and its use:

·       Data definition language(DDL)

·       Data manipulation language(DML)

·       Data control language(DCL)

·       Transaction control language(TCL)

Data definition language (DDL):

CREATE            –To create a database and its objects like, the create statement used to create a table, index, views, stored procedure, function, and triggers.

ALTER               – Modify or alter the structure of the existing database

DROP                 – Delete created objects from the database

TRUNCATE      – Remove all records from a table, including all spaces        allocated for the records are removed

COMMENT       – Add comments to the data dictionary

RENAME          – Rename an object

Data manipulation language (DML):

SELECT   – retrieve data from the database

INSERT    – insert data into a table

UPDATE  – updates existing data within a table

DELETE  – Delete all records from a database table

Data control language (DCL):

GRANT   – allow users access privileges to database

REVOKEwithdraw users access privileges given by using the GRANT command

Transaction control language (TCL):

COMMIT         commits a Transaction

ROLLBACK     – rollback a transaction because sometimes cause errors

SAVEPOINT     – rollback the transaction making points within groups

SET TRANSACTIONspecify characteristics for the transaction

 

Share:

Python - Operators

Operators:

Operators are special symbols that carry out arithmetic or logical or any other computation.

Types of Operators:

1.Arithmetic operator:

Used to perform mathematical operations like addition, subtraction and so on.


Operator
Description
Example
Output
+
Addition
a=5
b=5
print(a+b)

10
-
Subtraction
a=5
b=5
print(a-b)

0
*
Multiplication
a=5
b=5
print(a*b)

25
/
Division
a=5
b=5
print(a/b)

1
%
Modulo
a=5
b=5
print(a%b)
0

2.Floor division operator: 

This operator is similar to the division operator. It is used to display the nearest whole number. Using double slash operator "\\".

Example:


print('7/5 value is',7/5)

print('7//5 value is',7//5)

 Output:
3.Power operator:


This operator is similar to the multiplication operator. It is used to display the power values.

Example: 2**5


Output:   32

4.Assignment operator:

An assignment operator is used to set the values or doing some computations.


Operator
Description
Example
Output
=
Assignment
a=10
b=a
print(a,b)

10
+=
Addition Assignment
a=5
a+=5
print(a)

10
-=
Subtraction Assignment
a=5
a-=5
print(a)

0
*=
Multiplication Assignment
a=5
a*=5
print(a)

25
/=
Division Assignment
a=5
a/=5
print(a)

1
%=
Modulo Assignment
a=5
a%5=5
0


5.Relational operator:

This operator also called a comparison operator. It is used to compare the values. It either returns True or False based on conditions.


Operator
Description
Example
Output
Greater then
a=10
b=5
print(a>b)

True
Less then
a=10
b=5
print(a<b)

False
>=
Greater then or equal
a=10
b=5
print(a>=b)

True

<=
Less then or equal
a=10
b=5
print(a<=b)

False
==
Equal
a=5
b=5
print(a==b)

True
!=
Not equal
a=5
b=10
print(a==b)

False
6.Logical operator:
The logical operators for AND, OR and NOT are used to combine simple relational statements into more complex expressions. 


Previous                                                     Next


Share:

Recent Posts

Service Support

Need our help to Learn or Post New Concepts Contact me