Posts

Showing posts from March, 2026

Joins in Oracle SQL

 Joins ========== Primary Forign Key Relation Ship DEPT ((DEPTNO PK-Primary Key)  EMP (DEPTNO FK-Foreign Key) Cross Join ---------- select empno, ename, job, dname , loc from emp, dept; select empno, ename, job, dname , loc from emp, dept where ename='SCOTT'; Result: EMPNO ENAME JOB DNAME LOC ------------------------------------------ 7788 SCOTT ANALYST ACCOUNTING NEW YORK 7788 SCOTT ANALYST RESEARCH DALLAS 7788 SCOTT ANALYST SALES CHICAGO 7788 SCOTT ANALYST OPERATIONS BOSTON ------------------------------------------ Equi-Join --------- select empno, ename, job, dname , loc from emp, dept where 1=1 and emp.deptno=dept.deptno and ename='SCOTT'; Result: EMPNO, ENAME, JOB, DNAME, LOC --------------------------------------- 7788 SCOTT ANALYST RESEARCH DALLAS select empno, ename, job, dname , loc from emp, dept where 1=1 and emp.deptno=dept.deptno --and ename='SCOTT'; Result: EMPNO, ENAME, JOB, DNAME, ...

About Constraints in Oracle SQL

 Constraints ============ Constraints are conditions put on table columns. Oracle provides certain constraints that can be assigned to table columns. The total number of constraints are:  1.CHECK  2.UNIQUE  3.NOT NULL  4.PRIMARY KEY  5.FOREIGN KEY Check Constraint ---------------- A CHECK constraint can be used for validation,  for example, ensuring a hire date is greater than the company's establishment date. If a date lower than the establishment date is inserted, the constraint will throw an error. Unique Constraint ----------------- The UNIQUE constraint can be used to ensure a column, such as a cell number, has unique values for every person. A column with a UNIQUE constraint can allow records without a cell number (null values). Primary Key Constraint ---------------------- The PRIMARY KEY constraint is used to ensure values are both unique and not null. It achieves the goal of not allowing duplicate values and not allowing null values. If a PRIM...