0% found this document useful (0 votes)
9 views

DBMS PRG4 LAB

The document outlines the use of SQL Data Manipulation Language (DML) commands for querying and manipulating databases. It details commands such as INSERT, SELECT, UPDATE, and DELETE, providing syntax and examples for each. The results indicate that the DML commands were executed successfully.

Uploaded by

joyalprincess
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

DBMS PRG4 LAB

The document outlines the use of SQL Data Manipulation Language (DML) commands for querying and manipulating databases. It details commands such as INSERT, SELECT, UPDATE, and DELETE, providing syntax and examples for each. The results indicate that the DML commands were executed successfully.

Uploaded by

joyalprincess
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EX-NO : 4 QUERY THE DATABASE USING SQL

MANIPULATION
DATE :

AIM:
To Query the database using SQL manipulation.

DML commands are the most frequently used SQL commands and is used to query and manipulate the
existing database objects. Some of the commands are.

1. INSERT
This is used to add one or more rows to a table. The values are separated by commas and the data
types char and date are enclosed in apostrophes. The values must be entered in the same order as they are
defined.

2. SELECT
It is used to retrieve information from the table.it is generally referred to as querying the table.
We can either display all columns in a table or only specify column from the table.

3. UPDATE
It is used to alter the column values in a table. A single column may be updated or more than one
column could be updated.

4. DELETE
After inserting row in a table we can also delete them if required. The delete command consists
of a from clause followed by an optional where clause
PROCEDURE

1. INSERT COMMAND

(a) Inserting a single row into a table:


Syntax:
insert into <table name> values (<expression1>,<expression2>)

Example:
SQL> INSERT INTO students VALUES('Ram',25,'Male','Salem','9874563210');

SQL>Select *from students;

(b) To insert a record into a table without mention column names?


SQL> INSERT INTO students VALUES(NULL,'Ravi',23,'Male','Namakkal','9876543210');
SQL> SELECT *from students;

(c) Inserting more than one record using a single insert commands:
Syntax:
insert into <table name> values (&col1, &col2, ….),(&col1,&col2),….

Example
SQL> INSERT INTO students (name, age, gender, city, contact) VALUES
('Ravi',23,'Male','Namakkal','9876543210'),('Sara',23,'Female','Erode','9874521360');

SQL> select *from students


2. SELECT COMMAND

(a) View all rows and all columns


Syntax:
Select * from tablename;

Example:
SQL> select *from students;

(b) Selected Columns and All Rows


Syntax:
Select <column1>,<column2> from tablename;
Example:
SQL> select id,name,age from students ;

(c) Selected Columns And selected Rows


Syntax:
SELECT<column1>, <column2> FROM <tablename> WHERE <condition> ;
Example:
SQL> select *from students where id=1;

(d) Eliminating duplicate rows


Syntax;
SELECT DISTINCT <column1>, <column2> FROM <tablename>
Example:
SQL> SELECT DISTINCT city FROM students;
3. UPDATE COMMAND

(a) Updating records conditionally


SQL> UPDATE students SET city='Hosur',contact='9988776655' WHERE id=2;
SQL> select *from students;

4. DELETE COMMAND

(a) Removal of all rows


Syntax:
Delete from <table name> where <condition>;

Example:
DELETE FROM students WHERE id=3;

RESULT:
The DML commands are executed successfully.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy