BrainDump
  Home arrow BrainDump arrow Page 3 - More Advanced SQL Statements
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 
eWeek
 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: 5 stars5 stars5 stars5 stars5 stars / 7
    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:
      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

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    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


       · This is the third installment in my Beginner SQL series. It covers things like the...
     

       

    BRAINDUMP ARTICLES

    - Outsourcing: the Hoopla, the Reality
    - MySQL Plays in the Sun
    - All About SQL Functions
    - SQL: Functioning in the Real World
    - More Advanced SQL Statements
    - Beginning SQL the SEQUEL: Working with Advan...
    - Beginning SQL
    - A Look at the VI Editor
    - A Quick Tour of Boo
    - Book Review: Open Source Licensing
    - PGP and GPG: Email for the Practical Parano...
    - Microsoft Continues War on Open Source
    - Secure Remote Desktop Sharing with VNC on Li...
    - A Look at Google Project Hosting
    - What we can Learn from Two Linux vs. Microso...




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