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

DML Commands Documentation

Uploaded by

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

DML Commands Documentation

Uploaded by

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

DML COMMANDS

Title:

Demonstrate the data manipulation commands in SQL with the following table.

Table Name: Student

Column name Datatype Size


Sno Number 3
Sname Char 20
Course Char 10
Adate Date

Procedure:

Step-1:
Create the student table using create command with the above requirements.
SQL> create table student (sno number (3),
sname varchar (20),
course varchar (10),
adate date);
Table created.

Step-2:
To display the structure of student with “desc” command as follows:
SQL> desc student;
Name Null? Type
----------------------------------------- -------- ----------------------------
SNO NUMBER (3)
SNAME VARCHAR2(20)
COURSE VARCHAR2(10)
ADATE DATE

Step-3: Insert Command:


Using Insert command, we can add record or records into a table. It has three methods of
syntax as follows:

3.1: 1st method of syntax:


Insert into < table _name> (column name1, column name2,……. Column name n) values
(value1, valuie2…….value n);
Example:
SQL> insert into student (sno, sname, course, adate) values(10,’SURESH’,’BCA’,’30-JUL-24’);
1 row created.
SQL> select * from student;
SNO SNAME COURSE ADATE
---------- -------------------- ---------- ---------
10 SURESH BCA 30-JUL-24

3.2: 2nd method of syntax:


Insert into <table_name> Values (Value1, Value 2………. Value n);
Example:
SQL> insert into student values(20,'RAMESH','BSC','2-jan-24');
1 row created.
SQL> select * from student;
SNO SNAME COURSE ADATE
---------- ------------------- ---------- ---------
10 SURESH BCA 30-JUL-24
20 RAMESH BSC 02-JAN-24

3.3: 3rd method of syntax:


Insert into <table_name> values(&sno,’&sname’,’&course’,’&adate’);
Example:
SQL> insert into student values(&sno,'&sname','&course','&adate');Enter value for sno: 30
Enter value for sname: SWETHA
Enter value for course: BBA
Enter value for adate: 3-MAR-24
1 row created.
SQL> select * from student;
SNO SNAME COURSE ADATE
---------- -------------------- ---------- ---------
10 SURESH BCA 30-JUL-24
20 RAMESH BSC 02-JAN-24
30 SWETHA BBA 03-MAR-24

Step-4:
The table after inserting record is viewed using select command as follows:
SQL> select * from student;
SNO SNAME COURSE ADATE
---------- -------------------- ---------- ---------
10 SURESH BCA 30-JUL-24
20 RAMESH BSC 02-JAN-24
30 SWETHA BBA 03-MAR-24
40 KAVERI BBA 04-FEB-24
50 RAJU BCA 09-MAY-24
... up to 13 records...
Step-5: Delete Command:
Delete command is used to delete a record or records from a table.
Syntax:
Delete from <table_name> where condition;
Example:
To delete a record from student table using delete command as follows:
SQL> delete from student where sno=130;
1 row deleted.
SQL> select * from student;
SNO SNAME COURSE ADATE
... remaining rows...

Step-6: update command:


To modify the existing data in the existing table is done with update command as follows:
Syntax:
Update <table_name> set column name = expression where condition;
Example:
SQL> update student set sname='MAHESH' where sno=120;
1 row updated.
SQL> select * from student;
...updated rows...

Result:
Demonstrating the data manipulation commands using SQL has been successfully done.

You might also like