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

SQL_DML

The document outlines a series of SQL commands executed on an Oracle Database, including creating, inserting, updating, and deleting records in a 'freinds' table. It details the structure of the table and the operations performed, such as handling errors related to invalid inputs and unique constraints. The final state of the 'freinds' table shows two remaining entries after deletions.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL_DML

The document outlines a series of SQL commands executed on an Oracle Database, including creating, inserting, updating, and deleting records in a 'freinds' table. It details the structure of the table and the operations performed, such as handling errors related to invalid inputs and unique constraints. The final state of the 'freinds' table shows two remaining entries after deletions.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Enter user-name: scott

Enter password:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from tab;

TNAME TABTYPE CLUSTERID


------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
EMP TABLE
FREINDS TABLE
LUNCH TABLE
SALGRADE TABLE

6 rows selected.

SQL> describe freinds;


Name Null? Type
----------------------------------------- -------- ----------------------------
FNO NOT NULL NUMBER(2)
FNAME NOT NULL VARCHAR2(10)

SQL> select * from freinds;

no rows selected

SQL> insert into freinds values('1','Ganesh');

1 row created.

SQL> insert into freinds values('2','bhagya');

1 row created.

SQL> insert into freinds values('3','suma');

1 row created.

SQL> select * from tab;

TNAME TABTYPE CLUSTERID


------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
EMP TABLE
FREINDS TABLE
LUNCH TABLE
SALGRADE TABLE

6 rows selected.
SQL> select * from freinds;

FNO FNAME
---------- ----------
1 Ganesh
2 bhagya
3 suma

SQL> insert into freinds(fname,fno) values('madhu','4');

1 row created.

SQL> insert into freinds(fname,fno) values('4','mad');


insert into freinds(fname,fno) values('4','mad')
*
ERROR at line 1:
ORA-01722: invalid number

SQL> select * from freinds;

FNO FNAME
---------- ----------
1 Ganesh
2 bhagya
3 suma
4 madhu

SQL> update freinds


2 set fname='bhavani'
3 where fno='2';

1 row updated.

SQL> select * from freinds;

FNO FNAME
---------- ----------
1 Ganesh
2 bhavani
3 suma
4 madhu

SQL> update freinds


2 set fno='7',fname='kusum'
3 wehere fno=4;
wehere fno=4
*
ERROR at line 3:
ORA-00933: SQL command not properly ended

SQL> update freinds


2 set fno='7',fname='kusum'
3 wehere fno='4';
wehere fno='4'
*
ERROR at line 3:
ORA-00933: SQL command not properly ended
SQL> update freinds
2 set fno='7',fname='kusum'
3 where fno='4';

1 row updated.

SQL> select * from freinds;

FNO FNAME
---------- ----------
1 Ganesh
2 bhavani
3 suma
7 kusum

SQL> update freinds


2 set fno='2',fname='kusum'
3 where fno=''3';
ERROR:
ORA-01756: quoted string not properly terminated

SQL> update freinds


2 set fno='2',fname='kusum'
3 where fno='3';
update freinds
*
ERROR at line 1:
ORA-00001: unique constraint (SCOTT.SYS_C0011142) violated

SQL> select * from freinds;

FNO FNAME
---------- ----------
1 Ganesh
2 bhavani
3 suma
7 kusum

SQL> delete from freinds


2 where fno='3';

1 row deleted.

SQL> select * from freinds;

FNO FNAME
---------- ----------
1 Ganesh
2 bhavani
7 kusum

SQL> delete from freinds


2 where fname='bhavani';

1 row deleted.
SQL> select * from freinds;

FNO FNAME
---------- ----------
1 Ganesh
7 kusum

You might also like