Posts

Hi Friends , Lets Understand the Sequence with Examples Create  SEQUENCE XXEMPNO_SEQ START WITH 100 MAXVALUE   500 INCREMENT BY 1; Select XXEMPNO_SEQ.NEXTVAL from dual; Select XXEMPNO_SEQ.CURRVAL from dual; Create TABLE XXGH(EMPNO NUMBER, ENAME VARCHAR2(30)); Select * from XXGH; COMMIT; UPDATE XXGH SET EMPNO=106 where EMPNO=109; INSERT INTO XXGH(EMPNO,ENAME) VALUES(XXEMPNO_SEQ.NEXTVAL,'ANI'); COMMIT; DELETE FROM XXGH WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM XXGH GROUP BY EMPNO); Select * from  XXGH WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM XXGH GROUP BY EMPNO) / SELECT * FROM USER_OBJECTS WHERE OBJECT_NAME='XXEMPNO_SEQ' SELECT * FROM USER_SEQUENCES WHERE SEQUENCE_NAME='XXEMPNO_SEQ'; Select rownum ,E.* from EMP E order BY ENAME; / Select rownum ,E.* from EMP E  where DEPTNO=30 ;

Oracle PLSQL Examples

Hello Friends , Below are Some PLSQL Sample Anonymous and named Block Program for your quick pick. Please ask if you have any question Related to PLSQL. *************Program to print the string on to the screen***************************** DECLARE v_name VARCHAR2(100):='&Name'; BEGIN DBMS_OUTPUT.PUT_LINE(V_NAME); END; / *************Program to print the string on to the screen***************************** *************Program to find out the the odd/Even Number****************************** DECLARE V_NUM NUMBER:=# BEGIN IF MOD(V_NUM,2)=0 THEN DBMS_OUTPUT.PUT_LINE('THE NUMBER ENTERED'||V_NUM||' is an EVEN Number'); ELSE DBMS_OUTPUT.PUT_LINE('THE NUMBER ENTERED'||V_NUM||' is an ODD Number'); END IF; END; / *************Program to find out the the odd/Even Number****************************** *************Program to find out the the greater/lesses Number************************ DECLARE V_NUM1 NUMBER:=&NUM...
Hi Friends, Lets understand the Sub queries Which is an important concept in SQL. Sub query:-A sub query is a SELECT statement which is used in another SELECT statement. Sub queries are very useful when you need to select rows from a table with a condition that depends on the data of the table itself. You can use the sub query in the SQL clauses including WHERE clause, HAVING clause, FROM clause etc. The sub query can also be referred as nested SELECT, sub SELECT or inner SELECT. In general, the sub query executes first and its output is used in the main query or outer query. Types of Sub queries:- There are two types of sub queries in oracle: Single Row Sub queries: The sub query returns only one row. Use single row comparison operators like =, > etc while doing comparisons. SELECT * from emp where sal=(select max(sal) from emp); Multiple Row Sub queries: The sub query returns more than one row. Use multiple row comparison operators like IN, ANY, ALL in ...
Hi Friends, Let's give a brief light on Constraints Constraint:- It is the rule which restrict the incorrect data to be inserted into the database. Types of Constraint:- 1.     Not Null Constraint 2.     Unique   Constraint 3.     Check   Constraint 4.     Primary Key Constraint 5.     Foreign Key Constraint 6.     Ref Key(Referential Kay) Constraint TABLE LEVEL CONSTRAINT:- COLUMN LEVEL CONSTRAINT:- 1.     NOT NULL:-This is the constraints will avoid null values to the column specified. NOTE:- It is the only   constraint cannot be defined at Table level. Syntax:-Create table <table_name> (Empno NUMBER Constraint Empno_NN NOT NULL, ENAME VARCHAR2(30) NOT NULL ); SQL>   create table emp_info   2    (   3    empno number Constraint empno_pk Primary key,   4   ...

Constraints and Joins

Dear Friends Let's understand the rule of constraints in oracle. Constraint:- It is the rule which restrict the incorrect data to be inserted into the database. Types of Constraint 1.    Not Null Constraint 2.    Unique   Constraint 3.    Check   Constraint 4.    Primary Key Constraint 5.    Foreign Key Constraint 6.    Ref Key(Referential Kay) Constraint TABLE LEVEL CONSTRAINT:- COLUMN LEVEL CONSTRAINT:- 1.        NOT NULL:-This is the constraints will avoid null values to the column specified. NOTE :- It is the only   constraint cannot be defined at Table level. 2.    UNIQUE CONSTRAINT:- This is the constraint which will avoid duplicate values to the column specified. It can be specified at column level as well as table level.  3.    CHECK CONSTRAINT:-This is the constraint wh...