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

SQL DML

The document outlines the creation and manipulation of two tables, 'emp' and 'student', in a database. It includes commands for inserting, updating, and selecting records, as well as altering table structures. The document provides specific examples of data entries and updates for both tables, demonstrating SQL operations.

Uploaded by

Suwathi V
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

SQL DML

The document outlines the creation and manipulation of two tables, 'emp' and 'student', in a database. It includes commands for inserting, updating, and selecting records, as well as altering table structures. The document provides specific examples of data entries and updates for both tables, demonstrating SQL operations.

Uploaded by

Suwathi V
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Ex: 04:

Create table emp

(eno number(4),ename varchar2(15),salary number(6));

Table created.

desc emp

Name Null? Type

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

ENO NUMBER(4)

ENAME VARCHAR2(15)

SALARY NUMBER(6)

insert into emp values(&1,'&2',&3);

Enter value for 1: 1001

Enter value for 2: Employee1

Enter value for 3: 14000

old 1: insert into emp values(&1,'&2',&3)

new 1: insert into emp values(1001,'Employee1',14000)

1 row created.

Enter value for 1: 1002

Enter value for 2: Employee2

Enter value for 3: 6000

old 1: insert into emp values(&1,'&2',&3)

new 1: insert into emp values(1002,'Employee2',6000)

1 row created.

Enter value for 1: 1003

Enter value for 2: Employee3


Enter value for 3: 8000

old 1: insert into emp values(&1,'&2',&3)

new 1: insert into emp values(1003,'Employee3',8000)

1 row created.

Enter value for 1: 1004

Enter value for 2: Employee4

Enter value for 3: 7000

old 1: insert into emp values(&1,'&2',&3)

new 1: insert into emp values(1004,'Employee4',7000)

1 row created.

Enter value for 1: 1005

Enter value for 2: Employee5

Enter value for 3: 9000

old 1: insert into emp values(&1,'&2',&3)

new 1: insert into emp values(1005,'Employee5',9000)

1 row created.

select*from emp;

ENO ENAME SALARY

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

1001 Employee1 14000

1002 Employee2 6000

1003 Employee3 8000

1004 Employee4 7000

1005 Employee5 9000


Insert into emp(eno,ename)values(4,'Robert White');

1 row created.

Select*from emp;

ENO ENAME SALARY

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

1001 Employee1 14000

1002 Employee2 6000

1003 Employee3 8000

1004 Employee4 7000

1005 Employee5 9000

4 Robert White

Ex.05:

Update emp set ename = 'Suwathi'where eno=1003;

1 row updated.

Select*from emp;

ENO ENAME SALARY

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

1001 Employee1 14000

1002 Employee2 6000

1003 Suwathi 8000

1004 Employee4 7000

1005 Employee5 9000

4 Robert White

Alter table emp modify(ename varchar2(15));

Table altered.
select *from emp;

ENO ENAME SALARY

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

1001 Employee1 14000

1002 Employee2 6000

1003 Suwathi 8000

1004 Employee4 7000

1005 Employee5 9000

4 Robert White

Create table student (studentid number(01),Sname varchar(15),sage number(02),sdepartment varchar2(06));

Table created.

Select*from emp;

ENO ENAME SALARY

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

1001 Employee1 14000

1002 Employee2 6000

1003 Suwathi 8000

1004 Employee4 7000

1005 Employee5 9000

4 Robert White

desc student

Name Null? Type

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

STUDENTID NUMBER(1)

SNAME VARCHAR2(15)

SAGE NUMBER(2)

SDEPARTMENT VARCHAR2(6)

Insert into student values(&1,'&2',&3,'&4');


Enter value for 1: 1

Enter value for 2: A

Enter value for 3: 20

Enter value for 4: Tamil

old 1: Insert into student values(&1,'&2',&3,'&4')

new 1: Insert into student values(1,'A',20,'Tamil')

1 row created.

SQL> /

Enter value for 1: 2

Enter value for 2: B

Enter value for 3: 20

Enter value for 4: com

old 1: Insert into student values(&1,'&2',&3,'&4')

new 1: Insert into student values(2,'B',20,'com')

1 row created.

Update student set sage =23,sdepartment='Maths' where Studentid=1;

1 row updated.

Update Student set sage= sage+1 where sdepartment = 'ACC';

Select * from Student;

STUDENTID SNAME SAGE SDEPAR

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

1A 23 Maths

2B 20 com

You might also like