The below are some examples of writng a query with the select clause where we can Select some columns or all columns from the table…


The below are some examples of writng a query with the select clause where we can
Select some columns or all columns from the table…



1)      Write a Query to View all columns data from emp table…
Select * from emp; --when ever we say * it means display all the columns from the table
   
2)      Write a Query to View empno,ename,sal columns data from emp table…
Select  empno
            ,ename
            ,sal
from emp;
3)      Write a Query to View employee name and salary columns data from emp table…
Select ename
           ,sal
From emp;
4)      Write a Query to View employee name and department no data from emp table…
  Select ename
           ,deptno
From emp;

5)      Write a Query to View department name and location columns data from dept table…
 Select dname
           ,loc
From dept;

6)      Write a Query to View employee name, commission and salary columns data from emp table…
 Select ename
           ,comm
           ,sal
From emp;

7)      Write a Query to View department number columns data from dept table…
  Select deptno
   From dept;

8)      Write a Query to View salary,job,employee name details from emp table…
 Select sal
           , job
           , ename
From emp;
9)      Write a Query to View employee no,employee name,department no and also a hardcoded text ‘learn sql’ column  details from emp table…
 Select empno
           , ename
           ,deptno
           ,’learn sql’
From emp;

Note: when selecting any column from the table to print we can also select any harcoded text as a column along with them.This harcoded text will repeat for all the records which are being printed from the table….


Dual Table :

Dual is a table which is created by oracle along with the data dictionary.
 It consists of exactly one column whose name is dummy and one record.
The value of that record is X.

Select * from dual;
o/p :- X.

purpose of this table is mainly we use for the pseudo columns.

Example : select sysdate from dual;

Sysdate is an oracle provided column which returns date and time….
So, if I need todays date and time we can use the above query which again returns only one row.
Also we can use this table to practice some character or number functions which we will go through
In next sessions….
Dual Table




Post a Comment