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

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 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: 4 stars4 stars4 stars4 stars4 stars / 48
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Dell PowerEdge Servers

    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


       · if you provide information on triggers, views, and store procedures it is best
       · I'll write articles about view, triggers and PL/SQL...
     

       

    ORACLE ARTICLES

    - 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...
    - Sub-templates and More with Oracle HTML DB
    - Focusing on Templates in Oracle HTML DB

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway