Oracle
  Home arrow Oracle arrow Page 4 - Oracle Database Fundamentals
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ORACLE

Oracle Database Fundamentals
By: Mamun Zaman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 73
    2007-05-01


    Table of Contents:
  • Oracle Database Fundamentals
  • Creating Database Tables
  • Inserting Data
  • Selecting Data
  • Updating Data

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Oracle Database Fundamentals - Selecting Data
    ( Page 4 of 5 )

    The syntax for selecting data from an Oracle table is

    select columnname, columnname... from tablename;

    If we want to select data from our department table we will use

    select dept, empid, deptid from department;

    This will select all data from a department table. There is a shortcut version of selecting all data from a table, and that is *.

    select * from department;

    The above two SQL statements are the same. To get the count of records (rows) in a table use the count() function.

    select count(*) from department;

    To get the maximum value of a column we can use the max() function. Use the min() function to get the minimum.

    select max(salary) from employee;

    select min(salary) from employee;

    If we want to get the information about a particular employee whose first empid is 5 from our employee table, the SQL will be

    select * from employee where empid=5;

    In SQL we can add a where clause such as where empid=5 to get data that match the condition. There can be more than one where condition combined by 'and' and 'or'.

    We want to get the full name of the employees whose deptid is 1 and who earn more than 5000.

    select "First Name"||' '||'Last Name' from employee where deptid=1 and salary>5000;

    • In Oracle, || is used for string concatenation as well as concat() function.

    If you see the resulting column name then you can see it is the same as the expression we used in our SQL. We can give an alias for this expression using AS. For example:

    select "First Name"||' '||'Last Name' as 'Full Name' from employee where deptid=1 and salary>5000;

    or (without AS, it is the same)

    select "First Name"||' '||'Last Name' 'Full Name' from employee where deptid=1 and salary>5000;

    We can also give an alias to a table name in this way. We can sort the output of a SQL select using order by.

    select "First Name", 'Last Name', salary from employee where salary>5000 order by salary;

    The above SQL will select the first name, last name and salary from the employee table whose salary is more than 5000, and sort the result using salary in ascending order. The default order is ascending (asc).

    select "First Name", 'Last Name', salary from employee where salary>5000 order by salary asc;

    To put the list in descending order use desc.

    select "First Name", 'Last Name', salary from employee where salary>5000 order by salary desc;



     
     
    >>> More Oracle Articles          >>> More By Mamun Zaman
     

       

    ORACLE ARTICLES

    - Oracle's Turn to Play in the Sun
    - Implementing and Using Oracle`s Restore Poin...
    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT