0% found this document useful (0 votes)
47 views4 pages

DML

The document discusses various DML commands in SQL like CREATE, INSERT, SELECT, ALTER, UPDATE, DELETE, and DROP used for manipulating data in database tables. It provides examples of creating a tiger table and inserting, selecting, updating, deleting, and dropping data from the table.

Uploaded by

2020A28 HARINI M
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)
47 views4 pages

DML

The document discusses various DML commands in SQL like CREATE, INSERT, SELECT, ALTER, UPDATE, DELETE, and DROP used for manipulating data in database tables. It provides examples of creating a tiger table and inserting, selecting, updating, deleting, and dropping data from the table.

Uploaded by

2020A28 HARINI M
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

2.

DML COMMANDS
(DATA MANIPULATION LANGUGAE)

CREATE

SQL> create table tiger(sno number(4),sname varchar(30),mark1


number(3),mark2 number(3));

Table created.

DESCRIBE
SQL> desc tiger;
Name Null? Type
----------------------------------------- -------- ----------------------------
SNO NUMBER(4)
SNAME VARCHAR2(30)
MARK1 NUMBER(3)
MARK2 NUMBER(3)

INSERT

SQL> insert into tiger values(&sno,'&sname',&mark1,&mark2);


Enter value for sno: 111
Enter value for sname: aaa
Enter value for mark1: 89
Enter value for mark2: 90
old 1: insert into tiger values(&sno,'&sname',&mark1,&mark2)
new 1: insert into tiger values(111,'aaa',89,90)

1 row created.

SQL> /
Enter value for sno: 222
Enter value for sname: bbb
Enter value for mark1: 98
Enter value for mark2: 95
old 1: insert into tiger values(&sno,'&sname',&mark1,&mark2)
new 1: insert into tiger values(222,'bbb',98,95)

1 row created.

SQL> /
Enter value for sno: 333
Enter value for sname: ccc
Enter value for mark1: 100
Enter value for mark2: 98
old 1: insert into tiger values(&sno,'&sname',&mark1,&mark2)
new 1: insert into tiger values(333,'ccc',100,98)

1 row created

SELECT

SQL> select *from tiger;

SNO SNAME MARK1 MARK2


---------- ------------------------------ ---------- ----------
111 aaa 89 90
222 bbb 98 95
333 ccc 100 98

ALTER

SQL> alter table tiger add(tot number(6));

Table altered.

SQL> desc tiger;


Name Null? Type
----------------------------------------- -------- ----------------------------
SNO NUMBER(4)
SNAME VARCHAR2(30)
MARK1 NUMBER(3)
MARK2 NUMBER(3)
TOT NUMBER(6)

SQL> select *from tiger;

SNO SNAME MARK1 MARK2 TOT


---------- ------------------------------ ---------- ---------- ----------
111 aaa 89 90
2222 bbb 98 95
333 ccc 100 98
UPDATE
SQL> update tiger set tot=mark1+mark2 where sno=111;

1 row updated.

SQL> update tiger set tot=mark1+mark2 where sno=222;

1 row updated.

SQL> update tiger set tot=mark1+mark2 where sno=333;

1 row updated.

SQL> select *from tiger;

SNO SNAME MARK1 MARK2 TOT


---------- ------------------------------ ---------- ---------- ----------
111 aaa 89 90 179
222 bbb 98 95 193
333 ccc 100 98 198

DELETE
DELETE FROM t iger WHERE sno = 111 ;

SNO SNAME MARK1 MARK2 TOT


---------- ------------------------------ ---------- ---------- ----------

222 bbb 95 193


333 ccc 100 98 198

DELETE FROM t iger WHERE sna me = ‘ bbb’ ;

SNO SNAME MARK1 MARK2 TOT


---------- ------------------------------ ---------- ---------- ----------
333 ccc 100 98 198
COMMIT
SQL> commit;

Commit complete.

DROP
SQL> drop table tiger;

Table dropped.

You might also like