Posts

Showing posts from February, 2014
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    ename varchar2(20) Not Null,   5    Job varchar2(20)    Constraint job_NN Not Null,   6    MGR NUMBER Constraint mgr_ref References emp_info(empno),   7    HI