You are on page 1of 11

SQL> create table orders(

2 c_id number(5) primary key,


3 p_name varchar(20) not null,
4 price number(20));
create table orders(
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

SQL> slect *
SP2-0042: unknown command "slect *" - rest of line ignored.
SQL> select *
2 from orders
3
SQL> select *
2 from orders;

no rows selected

SQL> drop table orders;

Table dropped.

SQL> create table orders(


2 c_id number(5) primary key,
3 p_name varchar(20) not null,
4 price number(20));

Table created.

SQL> desc orders


Name Null? Type
----------------------------------------- -------- ----------------------------
C_ID NOT NULL NUMBER(5)
P_NAME NOT NULL VARCHAR2(20)
PRICE NUMBER(20)

SQL> create table customers(


2 c_name varchar(20) primary key,
3 c_add varchar(20) not null,
4 ph_nu number(10) noynull,
5 c_id number(5),
6 constraint sow foreign key(c_id) references orders(c_id);
ph_nu number(10) noynull,
*
ERROR at line 4:
ORA-00907: missing right parenthesis

SQL> create table customers(


2 c_name varchar(20) primary key,
3 c_add varchar(20) not null,
4 ph_nu number(10) notnull,
5 c_id number(5),
6 constraint sow foreign key(c_id) references orders(c_id);
ph_nu number(10) notnull,
*
ERROR at line 4:
ORA-00907: missing right parenthesis

SQL> create table customers(


2 c_name varchar(20) primary key,
3 c_add varchar(20) not null,
4 ph_nu number(10) not null,
5 c_id number(5),
6 constraint sow foreign key(c_id) references orders(c_id);
constraint sow foreign key(c_id) references orders(c_id)
*
ERROR at line 6:
ORA-00907: missing right parenthesis

SQL> create table customers(


2 c_name varchar(20) primary key,
3 c_add varchar(20) not null,
4 ph_nu number(10) not null,
5 c_id number(5),
6 constraint sow foreign key(c_id) references orders(c_id));

Table created.

SQL> desc customers


Name Null? Type
----------------------------------------- -------- ----------------------------
C_NAME NOT NULL VARCHAR2(20)
C_ADD NOT NULL VARCHAR2(20)
PH_NU NOT NULL NUMBER(10)
C_ID NUMBER(5)

SQL> alter table customers


2 add email varchar(20) not null;

Table altered.

SQL> desc customers


Name Null? Type
----------------------------------------- -------- ----------------------------
C_NAME NOT NULL VARCHAR2(20)
C_ADD NOT NULL VARCHAR2(20)
PH_NU NOT NULL NUMBER(10)
C_ID NUMBER(5)
EMAIL NOT NULL VARCHAR2(20)

SQL> alter table customers


2 drop column ph_nu;

Table altered.

SQL> desc customers


Name Null? Type
----------------------------------------- -------- ----------------------------
C_NAME NOT NULL VARCHAR2(20)
C_ADD NOT NULL VARCHAR2(20)
C_ID NUMBER(5)
EMAIL NOT NULL VARCHAR2(20)
SQL> alter table customers
2 rename column c_name to u_name;

Table altered.

SQL> desc customers


Name Null? Type
----------------------------------------- -------- ----------------------------
U_NAME NOT NULL VARCHAR2(20)
C_ADD NOT NULL VARCHAR2(20)
C_ID NUMBER(5)
EMAIL NOT NULL VARCHAR2(20)

SQL> create table pens(


2 p_name varchar(10) primary key,
3 cost number(5) not null,
4 color varchar(10));

Table created.

SQL> desc pens


Name Null? Type
----------------------------------------- -------- ----------------------------
P_NAME NOT NULL VARCHAR2(10)
COST NOT NULL NUMBER(5)
COLOR VARCHAR2(10)

SQL> drop table pens;

Table dropped.

SQL> desc pens


ERROR:
ORA-04043: object pens does not exist

SQL> select * from pens;


select * from pens
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> flashback table pens to before drop;

Flashback complete.

SQL> desc pens


Name Null? Type
----------------------------------------- -------- ----------------------------
P_NAME NOT NULL VARCHAR2(10)
COST NOT NULL NUMBER(5)
COLOR VARCHAR2(10)

SQL> drop table pens


2 d
3
SQL> drop table pens;
Table dropped.

SQL> purge table pens;

Table purged.

SQL> flashback table pens to before pens;


flashback table pens to before pens
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> desc pens


ERROR:
ORA-04043: object pens does not exist

SQL> create table pens(


2 p_name varchar(10) primary key,
3 cost number(5) not null,
4 color varchar(10));

Table created.

SQL> drop table pens;

Table dropped.

SQL> purge table pens;

Table purged.

SQL> flashback table demo to before pens;


flashback table demo to before pens
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> create table pens(


2 p_name varchar(10) primary key,
3 cost number(5) not null,
4 color varchar(10));

Table created.

SQL> desc pens


Name Null? Type
----------------------------------------- -------- ----------------------------
P_NAME NOT NULL VARCHAR2(10)
COST NOT NULL NUMBER(5)
COLOR VARCHAR2(10)

SQL> select * from pens;

no rows selected

SQL> insert into pens values('cello','5','blue');


1 row created.

SQL> insert into pens values('doms','10','red');

1 row created.

SQL> select
2
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> select * from pens;

P_NAME COST COLOR


---------- ---------- ----------
cello 5 blue
doms 10 red

SQL> drop table pens;

Table dropped.

SQL> desc pens


ERROR:
ORA-04043: object pens does not exist

SQL> select * from pens;


select * from pens
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> flasback table pens to before drop;


SP2-0734: unknown command beginning "flasback t..." - rest of line ignored.
SQL> flashback table pens to before drop;

Flashback complete.

SQL> desc pens


Name Null? Type
----------------------------------------- -------- ----------------------------
P_NAME NOT NULL VARCHAR2(10)
COST NOT NULL NUMBER(5)
COLOR VARCHAR2(10)

SQL> slect * from pens;


SP2-0734: unknown command beginning "slect * fr..." - rest of line ignored.
SQL> select * from pens;
P_NAME COST COLOR
---------- ---------- ----------
cello 5 blue
doms 10 red

SQL> drop table pens;

Table dropped.

SQL> purge table pens;

Table purged.

SQL> flashback table pens to before pens;


flashback table pens to before pens
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> table trancate table pens;


SP2-0734: unknown command beginning "table tran..." - rest of line ignored.
SQL> trancate table pens;
SP2-0734: unknown command beginning "trancate t..." - rest of line ignored.
SQL> create table pens(
2 p_name varchar(10) primary key,
3 cost number(5) not null,
4 color varchar(10));

Table created.

SQL> insert into pens values('cello','5','blue');

1 row created.

SQL> insert into pens values('doms','10','red');

1 row created.

SQL>
SQL> purge table pens;
purge table pens
*
ERROR at line 1:
ORA-38307: object not in RECYCLE BIN

SQL> select * from pens;

P_NAME COST COLOR


---------- ---------- ----------
cello 5 blue
doms 10 red

SQL> trancate table pens;


SP2-0734: unknown command beginning "trancate t..." - rest of line ignored.
SQL> truncate table pens;
Table truncated.

SQL> select * from pens;

no rows selected

SQL> desc pens;


Name Null? Type
----------------------------------------- -------- ----------------------------
P_NAME NOT NULL VARCHAR2(10)
COST NOT NULL NUMBER(5)
COLOR VARCHAR2(10)

SQL> rename pens to pound;

Table renamed.

SQL> desc pound


Name Null? Type
----------------------------------------- -------- ----------------------------
P_NAME NOT NULL VARCHAR2(10)
COST NOT NULL NUMBER(5)
COLOR VARCHAR2(10)

SQL> desc pens


ERROR:
ORA-04043: object pens does not exist

SQL> insert into sample values('bhagya','loptop');


insert into sample values('bhagya','loptop')
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> insert into orders values('10','fridge','15000');

1 row created.

SQL> insert into orders(c_id,p_name,price)values('20','makeupkit','4000');

1 row created.

SQL> select * from ordes;


select * from ordes
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> select * from orders;

C_ID P_NAME PRICE


---------- -------------------- ----------
10 fridge 15000
20 makeupkit 4000

SQL> insert into orders values('10','fridge','15000','lg');


insert into orders values('10','fridge','15000','lg')
*
ERROR at line 1:
ORA-00913: too many values

SQL> insert into order value('10');


insert into order value('10')
SQL> hikjjiiii
SP2-0042: unknown command "hikjjiiii" - rest of line ignored.
SQL> spool off
SQL> show user
USER is "HR"
SQL> create table face cream(
2 cream_name varchar(15),
3 price number(10),
4 mfr_date date);
create table face cream(
*
ERROR at line 1:
ORA-00922: missing or invalid option

SQL> create table facecream(


2 cream_name varchar(15),
3 price number(10),
4 mfr_date date);

Table created.

SQL> grant select,insert,delete on facecream to scott;

Grant succeeded.

SQL> conn
Enter user-name: scott
Connected.
SQL> select * from hr.facecream;

no rows selected

SQL> desc hr.facecream


Name Null? Type
----------------------------------------- -------- ----------------------------
CREAM_NAME VARCHAR2(15)
PRICE NUMBER(10)
MFR_DATE DATE

SQL> insert into facecream values('fair and lovely',45,'20-OCT-21');


insert into facecream values('fair and lovely',45,'20-OCT-21')
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> insert into hr.facecream values('fair and lovely',45,'20-OCT-21');

1 row created.
SQL> insert into hr.facecream values('GARNIER',55,'22-FEB-21');

1 row created.

SQL> COMMIT
2
SQL> COMMIT;

Commit complete.

SQL> SELECT * from hr.facecream;

CREAM_NAME PRICE MFR_DATE


--------------- ---------- ---------
fair and lovely 45 20-OCT-21
GARNIER 55 22-FEB-21

SQL> insert into hr.facecream values('ponds',35,'12-FEB-21');

1 row created.

SQL> select * from hr.facecream;

CREAM_NAME PRICE MFR_DATE


--------------- ---------- ---------
fair and lovely 45 20-OCT-21
GARNIER 55 22-FEB-21
ponds 35 12-FEB-21

SQL> savepoint sow;

Savepoint created.

SQL> rollback sow;


rollback sow
*
ERROR at line 1:
ORA-02181: invalid option to ROLLBACK WORK

SQL> roll back sow;


Rollback complete.
SQL> select * from hr.facecream;

CREAM_NAME PRICE MFR_DATE


--------------- ---------- ---------
fair and lovely 45 20-OCT-21
GARNIER 55 22-FEB-21

SQL> conn
Enter user-name: hr
Connected.
SQL> revoke select,insert,delete on facecream from scott;

Revoke succeeded.

SQL> commit;

Commit complete.
SQL> spool off

*
ERROR at line 1:
ORA-00903: invalid table name

SQL> select * from orders;

C_ID P_NAME PRICE


---------- -------------------- ----------
10 fridge 15000
20 makeupkit 4000

SQL> update orders set c_id='60',p_name='book',price='1000'


2 l
3
SQL> update orders set c_id='10',p_name='book',price='15000'
2 where lower(p_name)='fridge';

1 row updated.

SQL> select * from orders;

C_ID P_NAME PRICE


---------- -------------------- ----------
10 book 15000
20 makeupkit 4000

SQL> insert into orders (c_id,p_name,price)values('30','laptop','30000');

1 row created.

SQL> select * from orders;

C_ID P_NAME PRICE


---------- -------------------- ----------
10 book 15000
20 makeupkit 4000
30 laptop 30000

SQL> update orders set p_name='cloths'


2 where lower(p_name)='laptop';

1 row updated.

SQL> select * from orders;

C_ID P_NAME PRICE


---------- -------------------- ----------
10 book 15000
20 makeupkit 4000
30 cloths 30000

SQL> update orders set p_name='phone';

3 rows updated.
SQL> select * from orders;

C_ID P_NAME PRICE


---------- -------------------- ----------
10 phone 15000
20 phone 4000
30 phone 30000

SQL> deletefrom order


SP2-0734: unknown command beginning "deletefrom..." - rest of line ignored.
SQL> delete from orders
2 where lower(c_id)='20';

1 row deleted.

SQL> select * from orders;

C_ID P_NAME PRICE


---------- -------------------- ----------
10 phone 15000
30 phone 30000

SQL> spool off

You might also like