Académique Documents
Professionnel Documents
Culture Documents
commit
rollback
commit;
---------constraints-------rules -------
---------------
select * from stdds where fees between 5000 and 6000;
select * from stdds where fees > 6000 and fees < 9000;
SQL> connect
Enter user-name: system
Enter password:
Connected.
SQL> create table stdds (
2 rollnum number,
3 sname varchar(20),
4 fees number,
5 dob date
6 );
Table created.
1 row created.
SQL>
SQL> insert into stdds values (2,'admin',15000,'11-jan-1988');
1 row created.
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL> select * from stdds;
SQL>
SQL>
SQL>
SQL> select * from stdds where fees is not null;
SQL>
SQL> select * from stdds where fees > 5000;
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> select sname from stdds where fees > 5000;
SNAME
--------------------
admin
SQL>
SQL> select sname,fees from stdds where fees > 5000;
SNAME FEES
-------------------- ----------
admin 15000
SQL>
SQL>
SQL>
SQL> insert into stdds values (3,'def',null,'11-jan-1988');
1 row created.
Table dropped.
Table created.
SQL> desc stdds;
Name Null? Type
----------------------------------------- -------- ----------------------------
ROLLNUM NOT NULL NUMBER
SNAME NOT NULL VARCHAR2(20)
FEES NUMBER
DOB DATE
CONT NUMBER
CITY VARCHAR2(20)
SQL>
SQL> insert into stdds values (&rollnum,'&sname',&fees,'&dob',&cont,'&city');
Enter value for rollnum: 1
Enter value for sname: raj
Enter value for fees: 10000
Enter value for dob: 11-jan-1999
Enter value for cont: 123
Enter value for city: ahd
old 1: insert into stdds values (&rollnum,'&sname',&fees,'&dob',&cont,'&city')
new 1: insert into stdds values (1,'raj',10000,'11-jan-1999',123,'ahd')
1 row created.
SQL> /
Enter value for rollnum: 2
Enter value for sname: vipul
Enter value for fees: 6000
Enter value for dob: 22-june-1988
Enter value for cont: 12
Enter value for city: surat
old 1: insert into stdds values (&rollnum,'&sname',&fees,'&dob',&cont,'&city')
new 1: insert into stdds values (2,'vipul',6000,'22-june-1988',12,'surat')
1 row created.
SQL> r
1* insert into stdds values (&rollnum,'&sname',&fees,'&dob',&cont,'&city')
Enter value for rollnum: 3
Enter value for sname: admin
Enter value for fees: 6500
Enter value for dob: 5-apr-1985
Enter value for cont: 123
Enter value for city: surat
old 1: insert into stdds values (&rollnum,'&sname',&fees,'&dob',&cont,'&city')
new 1: insert into stdds values (3,'admin',6500,'5-apr-1985',123,'surat')
insert into stdds values (3,'admin',6500,'5-apr-1985',123,'surat')
*
ERROR at line 1:
ORA-00001: unique constraint (SYSTEM.SYS_C004215) violated
SQL> /
Enter value for rollnum: 3
Enter value for sname: admin
Enter value for fees: 6500
Enter value for dob: 5-apr-1985
Enter value for cont: 21323
Enter value for city: surat
old 1: insert into stdds values (&rollnum,'&sname',&fees,'&dob',&cont,'&city')
new 1: insert into stdds values (3,'admin',6500,'5-apr-1985',21323,'surat')
1 row created.
SQL> commit;
Commit complete.
SQL> select * from stdds select * from stdds where fees between 5000 and 6000;
select * from stdds select * from stdds where fees between 5000 and 6000
*
ERROR at line 1:
ORA-00933: SQL command not properly ended
SQL> select * from stdds where fees between 5000 and 6000;
SQL> select * from stdds where fees > 6000 and fees < 9000;
SQL>
SQL> select city from stdds;
CITY
--------------------
ahd
surat
surat
CITY
--------------------
ahd
surat
SQL>
SQL>
SQL>
SQL>
SQL> select * from stdds where city not in ('su','surat','baroda');
***************************************
SQL> connect
Enter user-name: system
Enter password:
Connected.
SQL> s
SP2-0042: unknown command "s" - rest of line ignored.
SQL>
SQL>
SQL>
SQL>
SQL> select * from stdds;
SQL>
SQL>
SQL> select sum(fees) from stdds;
SUM(FEES)
----------
22500
AVG(FEES)
----------
7500
COUNT(FEES)
-----------
3
MAX(FEES)
----------
10000
MIN(FEES)
----------
6000
STDDEV(FEES)
------------
2179.44947
STDDEV(FEES)
------------
2179.44947
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> select * froms stdds;
select * froms stdds
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
COUNT(CITY)
-----------
3
COUNT(CITY)
-----------
1
2
CITY COUNT(CITY)
-------------------- -----------
ahd 1
surat 2
SQL> select city,count(city) from stdds where fees > 0 group by city having
count(city) > 1 ;
CITY COUNT(CITY)
-------------------- -----------
surat 2
SQL> select city,count(city) from stdds where fees > 0 group by city having
count(city) > po ;
select city,count(city) from stdds where fees > 0 group by city having count(city)
> po
*
ERROR at line 1:
ORA-00904: "PO": invalid identifier
SQL> select city,count(city) from stdds where fees > 0 group by city having
count(city) > 0 ;
CITY COUNT(CITY)
-------------------- -----------
ahd 1
surat 2
SQL> select city,count(city) from stdds where fees > 0 group by city having
count(city) > 0 ;
CITY COUNT(CITY)
-------------------- -----------
ahd 1
surat 2
SQL> select city,count(city) from stdds where fees > 0 group by city having
count(city) > 1 ;
CITY COUNT(CITY)
-------------------- -----------
surat 2
SQL>
SQL>
SQL> select count(*) from stdds;
COUNT(*)
----------
3
COUNT(FEES)
-----------
3
SQL>
SQL>
SQL> update stdds set fees = fees + (fees * 0.10);
3 rows updated.
SQL> update stdds set fees = fees + (fees * 0.10) where city like 'surat' ;
2 rows updated.
SQL> commit;
Commit complete.
SQL>
SQL> delete from stdds;
3 rows deleted.
no rows selected
SQL> rollback;
Rollback complete.
SQL> commit;
Commit complete.
1 row deleted.
SQL> rollback;
Rollback complete.
SQL> commit;
Commit complete.
SQL>
SQL>
SQL>
SQL> select * from stdds union select * from stdds;
6 rows selected.
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> alter table stdds add rank number;
Table altered.
SQL> desc stdds;
Name
Null? Type
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
--------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
ROLLNUM
NUMBER
DOB
DATE
CONT
NUMBER
CITY
VARCHAR2(20)
RANK
NUMBER
SQL>
SQL>
SQL> select * from stdds;
Table renamed.
Null? Type
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
--------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
ROLLNUM
DATE
CONT
NUMBER
CITY
VARCHAR2(20)
RANK
NUMBER
SQL>
SQL>
SQL> select * from stdds;
select * from stdds
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from std123;
SQL>
SQL>