BrainDump
  Home arrow BrainDump arrow Page 3 - More Advanced SQL Statements
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? 
BRAINDUMP

More Advanced SQL Statements
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 13
    2007-10-08


    Table of Contents:
  • More Advanced SQL Statements
  • UNION STATEMENT
  • And along came baby
  • Speeding Up the Search
  • OOPS I DID IT AGAIN

  • 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


    More Advanced SQL Statements - And along came baby
    ( Page 3 of 5 )

    Now that we've wedded some tables in unholy matrimony and made some babies, let's add to our amazing powers and learn the CREATE statement.

    With the CREATE statement you can create new tables and even an entirely new database. Before we do however, let's discuss data types.

    In short, the data type defines what sort of data a column can hold. If you signify that a field is a date field, and try to enter text into that field, your database will yell at you. Everything has a place, and put the proper things there. And close the door. What, were you born in a barn?

    The following table shows the different data types available.

    Data Type

    Function

    CHAR

    For character strings with a fixed-length

    VARCHAR

    For character strings with variable lengths

    INT

    For integer numbers

    Numeric

    For holding numbers with decimals

    Float

    For numbers with floating points

    Date

    For dates

    Time

    For times

    TIMESTAMP

    For dates and times

    INTERVAL

    For holding time intervals

    There are other forms of data types, but they are beyond the scope of this article. For the time being, these should suffice.

    So now your boss wants a new database. This one will show the employees' names and how long they have been with the company. We will call this database Seniority. To create the database in SQL, do the following:

     

    CREATE DATABASE SENIORITY;

    It's just that simple. Or is it? Of course it isn't. We also need a table for our database. So let's create that now.


    CREATE TABLE SENIORITY

    (

    EmployeeName VARCHAR,

    YearsEmployed INT

    )




     
     
    >>> More BrainDump Articles          >>> More By James Payne
     

       

    BRAINDUMP ARTICLES

    - Demystifying SELinux on Kernel 2.6
    - Yahoo and Microsoft Create Ad Partnership
    - The Advantages of Obscure Open Source Browse...
    - Dell Announces CSI-style Digital Forensics S...
    - Milepost GCC Speeds Open-Source Development
    - Learn These 10 Programming Languages
    - Tomcat Capacity Planning
    - Internal and External Performance Tuning wit...
    - Tomcat Benchmark Procedure
    - Benchmarking Tomcat Performance
    - Tomcat Performance Tuning
    - Wubi: Windows-based Ubuntu Installer
    - Configuring and Optimizing Your I/O Scheduler
    - Linux I/O Schedulers
    - Advising the Linux Kernel on File I/O





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