Oracle DML Practice

What is Data Manipulation Language (DML)?

DML is referred to as a programming language that performs SELECT, INSERT, UPDATE, and DELETE operations. DML is some kind of command that manipulate data of oracle database tables.

 Command Examples are-

PGDICT4D Batch 13

/*

--select 5*9 from dual;

-- Table creation

create table student (st_roll number(4) primary key,

st_name varchar2(20), st_group char(1), st_beng number(3),

st_eng number(3), st_math number(3), st_total number(3));

select * from tab;

*/

insert into student

(st_roll,st_name,st_group,st_beng,st_eng,st_math)

VALUES

(1000,'Md. Abdur Rashid','S',42,90,100);

insert into student

(st_roll,st_name,st_group,st_beng,st_eng,st_math)

VALUES

(1001,'Md. Adur Salam','S',42,70,100);

insert into student

(st_roll,st_name,st_group,st_beng,st_eng,st_math)

VALUES

(1002,'Md. Abdur Gaful','S',42,70,100);

insert into student

(st_roll,st_name,st_group,st_beng,st_eng,st_math)

VALUES

(1003,'Mohsena','S',90,90,100);

insert into student

(st_roll,st_name,st_group,st_beng,st_eng,st_math)

VALUES

(1004,'Abdus Salam','S',42,90,100);

insert into student

(st_roll,st_name,st_group,st_beng,st_eng,st_math)

VALUES

(1005,'Khokon','S',85,90,100);

insert into student

(st_roll,st_name,st_group,st_beng,st_eng,st_math)

VALUES

(1006,'Mr. Nobel','S',75,90,100);

insert into student

(st_roll,st_name,st_group,st_beng,st_eng,st_math)

VALUES

(1007,'Mr. Nobel','S',75,90,100);

/*

delete from student

where st_roll=1002;

*/




-- Table creation


DROP TABLE student;


-- Table Creation


create table student

(roll number(6),

name varchar2(20),sex char(1),CONSTRAINT STUDENT_ROLL_PK PRIMARY KEY (ROLL));

SELECT roll, name, sex FROM student;

-- Insert


insert into student (roll,name,sex) values (100000,'Md. Abdur RASHID','0');


insert into student (roll,name,sex) values (100001,'Md. Abdul Hamid','0');


insert into student (roll,name,sex) values (100002,'Md. Selimul Haque','0');


insert into student (roll,name,sex) values (100003,'Sharmin Akhtar','1');


insert into student (roll,name,sex) values (100004,'Debasis Das','0');


insert into student (roll,name,sex) values (100005,'Samsul Islam','0');


insert into student (roll,name,sex) values (100006,'Nasrin Yasmin','1');


insert into student (roll,name,sex) values (100007,'Sharmin Akhtar','1');


insert into student (roll,name,sex) values (100008,'Debasis Das','0');


insert into student (roll,name,sex) values (100009,'Rezaul Karim','0');


insert into student (roll,name,sex) values (100010,'Shamima Sultana','1');


cl scr;


-- Update


UPDATE student                    

SET name= 'Md. Nizam Uddin'

WHERE roll=100002;


SELECT roll, name, sex FROM student;


-- Multiple Conditions


UPDATE student                    

SET name= 'Md.Akbor Ali'

WHERE roll=100002 AND sex='0';



-- Conditional Delete


DELETE FROM student 

WHERE roll=100006;



-- Changing field width


ALTER TABLE student

MODIFY (name VARCHAR2(25));


-- Adding column


ALTER TABLE student

ADD (fname VARCHAR2(20));


-- Changing table name


RENAME student TO student1;


ALTER TABLE student1

DROP COLUMN fname;


ALTER TABLE student1

MODIFY (name VARCHAR2(24));



DESC student1;


cl scr;



SELECT roll, name, sex FROM student1;


SELECT roll, length(name), sex FROM student1

WHERE LENGTH(name) >=15;


cl scr;


SELECT max(roll), min(roll) FROM student1;



www.rashid-bd.info


Comments

Popular posts from this blog

How to be an Innovative Speaker?

Developing Personal Skills

Differences between the terms Science, Technology, and Engineering