0% found this document useful (0 votes)
32 views5 pages

Oracle SQL Sequence and Table Operations

The document contains a log of SQL commands executed in an Oracle Database environment, including the creation of sequences and tables, as well as various SQL queries and errors encountered. It demonstrates the creation of an employee table and the insertion of records, along with attempts to use sequences for generating unique IDs. Additionally, it includes error messages related to SQL syntax and object existence within the database.

Uploaded by

rethinakumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views5 pages

Oracle SQL Sequence and Table Operations

The document contains a log of SQL commands executed in an Oracle Database environment, including the creation of sequences and tables, as well as various SQL queries and errors encountered. It demonstrates the creation of an employee table and the insertion of records, along with attempts to use sequences for generating unique IDs. Additionally, it includes error messages related to SQL syntax and object existence within the database.

Uploaded by

rethinakumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Microsoft Windows [Version 10.0.19045.

5371]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Administrator>sqlplus

SQL*Plus: Release [Link].0 Production on Wed Jan 29 [Link] 2025

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Enter user-name: wcf20jan


Enter password:

Connected to:
Oracle Database 11g Express Edition Release [Link].0 - 64bit Production

SQL> create sequence demo2_seq start with 100 increment by 100;

Sequence created.

SQL> select 100+100 srom dual;


select 100+100 srom dual
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

SQL> select 100+100 from dual;

100+100
----------
200

SQL> select demo2_seq.currval from dual;


select demo2_seq.currval from dual
*
ERROR at line 1:
ORA-08002: sequence DEMO2_SEQ.CURRVAL is not yet defined in this session

SQL> desc dual


Name Null? Type
----------------------------------------- -------- ----------------------------
DUMMY VARCHAR2(1)

SQL> select demo2_seq.nextval from dual;

NEXTVAL
----------
100

SQL> select demo2_seq.nextval from dual;

NEXTVAL
----------
200

SQL> select demo2_seq.nextval from dual;

NEXTVAL
----------
300

SQL> select demo2_seq.nextval from dual;

NEXTVAL
----------
400

SQL> desc emp


ERROR:
ORA-04043: object emp does not exist

SQL> create sequence eid_seq start with 100 increment by 100;

Sequence created.

SQL> desc employee


ERROR:
ORA-04043: object employee does not exist

SQL> desc emp


ERROR:
ORA-04043: object emp does not exist

SQL> ed
Wrote file [Link]

1 create table Emp


2 (
3 EMP_ID NUMBER(6) Primary Key,
4 NAME VARCHAR2(20),
5 SALARY NUMBER(8,2)
6* )
7 /

Table created.

SQL> desc emp


Name Null? Type
----------------------------------------- -------- ----------------------------
EMP_ID NOT NULL NUMBER(6)
NAME VARCHAR2(20)
SALARY NUMBER(8,2)

SQL> select * from emp;

EMP_ID NAME SALARY


---------- -------------------- ----------
200 Rathna 5000

SQL> select * from emp;

EMP_ID NAME SALARY


---------- -------------------- ----------
200 Rathna 5000
300 sriram 60000

SQL> select * from emp;

EMP_ID NAME SALARY


---------- -------------------- ----------
200 Rathna 5000
300 sriram 60000
400 radha 25000

SQL> insert values into emp('rathna2', 55000);


insert values into emp('rathna2', 55000)
*
ERROR at line 1:
ORA-00925: missing INTO keyword

SQL> insert into emp('rathna2', 55000);


insert into emp('rathna2', 55000)
*
ERROR at line 1:
ORA-00928: missing SELECT keyword

SQL> insert into emp values('rathna2', 55000);


insert into emp values('rathna2', 55000)
*
ERROR at line 1:
ORA-00947: not enough values

SQL> insert into values emp('rathna2', 55000);


insert into values emp('rathna2', 55000)
*
ERROR at line 1:
ORA-00903: invalid table name

SQL> insert into emp(emp_id, name,salary) values ('Rathnakumari', 55000);


insert into emp(emp_id, name,salary) values ('Rathnakumari', 55000)
*
ERROR at line 1:
ORA-00947: not enough values

SQL> insert into emp(emp_id, name,salary) values (400,'Rathnakumari', 55000);


insert into emp(emp_id, name,salary) values (400,'Rathnakumari', 55000)
*
ERROR at line 1:
ORA-00001: unique constraint (WCF20JAN.SYS_C007007) violated

SQL> INSERT INTO emp (emp_id, name, salary) VALUES (emp_seq.NEXTVAL,


'Rathnakumari', 55000);
INSERT INTO emp (emp_id, name, salary) VALUES (emp_seq.NEXTVAL, 'Rathnakumari',
55000)
*
ERROR at line 1:
ORA-02289: sequence does not exist
SQL> INSERT INTO emp (emp_id, name, salary) VALUES (101, 'Rathnakumari', 55000);

1 row created.

SQL> desc emp;


Name Null? Type
----------------------------------------- -------- ----------------------------
EMP_ID NOT NULL NUMBER(6)
NAME VARCHAR2(20)
SALARY NUMBER(8,2)

SQL> select * from emp;

EMP_ID NAME SALARY


---------- -------------------- ----------
200 Rathna 5000
300 sriram 60000
400 radha 25000
101 Rathnakumari 55000

SQL> select * from emp;

EMP_ID NAME SALARY


---------- -------------------- ----------
200 Rathna 5000
300 sriram 60000
400 radha 25000
101 Rathnakumari 55000
500 raju 30000

SQL> INSERT INTO emp (emp_id, name, salary) VALUES (eid_seq.NEXTVAL, 'Vijaya',
40000);

1 row created.

SQL> select * from emp;

EMP_ID NAME SALARY


---------- -------------------- ----------
200 Rathna 5000
300 sriram 60000
400 radha 25000
101 Rathnakumari 55000
500 raju 30000
600 Vijaya 40000

6 rows selected.

SQL> desc dba_users


Name Null? Type
----------------------------------------- -------- ----------------------------
USERNAME NOT NULL VARCHAR2(30)
USER_ID NOT NULL NUMBER
PASSWORD VARCHAR2(30)
ACCOUNT_STATUS NOT NULL VARCHAR2(32)
LOCK_DATE DATE
EXPIRY_DATE DATE
DEFAULT_TABLESPACE NOT NULL VARCHAR2(30)
TEMPORARY_TABLESPACE NOT NULL VARCHAR2(30)
CREATED NOT NULL DATE
PROFILE NOT NULL VARCHAR2(30)
INITIAL_RSRC_CONSUMER_GROUP VARCHAR2(30)
EXTERNAL_NAME VARCHAR2(4000)
PASSWORD_VERSIONS VARCHAR2(8)
EDITIONS_ENABLED VARCHAR2(1)
AUTHENTICATION_TYPE VARCHAR2(8)

SQL> sho user


USER is "WCF20JAN"
SQL> ed
Wrote file [Link]

1 create table courseTB


2 (
3 CRSID varchar(5) primary key,
4 CRSNAME varchar(30) not null,
5 DURATION number check(duration >=1),
6 FEE number check(fee>10000)
7* )
8 /

Table created.

SQL> desc courseTB


Name Null? Type
----------------------------------------- -------- ----------------------------
CRSID NOT NULL VARCHAR2(5)
CRSNAME NOT NULL VARCHAR2(30)
DURATION NUMBER
FEE NUMBER

SQL> crerate sequence crid_seq start with 1 increment by 1;


SP2-0734: unknown command beginning "crerate se..." - rest of line ignored.
SQL> create sequence crid_seq start with 1 increment by 1;

Sequence created.

SQL>

You might also like