Perl
  Home arrow Perl arrow Page 4 - Creating a Database with Perl and DBI
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 
 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? 
PERL

Creating a Database with Perl and DBI
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-03-20

    Table of Contents:
  • Creating a Database with Perl and DBI
  • The DESCRIBE Command
  • The INSERT Command
  • The SELECT Command

  • 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.

    Creating a Database with Perl and DBI - The SELECT Command
    (Page 4 of 4 )

    The SELECT command allows us to query the database, and it reports back to us the information that matches the criteria we specify from the table we indicate. We have seen severalSELECTcommands in this form:

    mysql> SELECT * FROM musicians; 

     player_id

     name

     phone

     1

     Roger Waters

     555-1212 

     2

     Geddy Lee

     555-2323 

     3

     Marshall Mathers III

     555-3434 

     4

     Thom Yorke

     555-4545 

     5

     Lenny Kravitz

     555-5656 

     6

     Mike Diamond

     555-6767 

     

    6 rows in set (0.00 sec)

    ThisSELECTasks for*from the table namedmusicians. The*means “all fields” in the order that they are in the table. We can explicitly ask for the fields by listing them comma separated instead of using the star.

    mysql> SELECT player_id, name, phone FROM musicians;

     player_id

     name

     phone

     1

     Roger Waters

     555-1212 

     2

     Geddy Lee

     555-2323 

     3

     Marshall Mathers III

     555-3434 

     4

     Thom Yorke

     555-4545 

     5

     Lenny Kravitz

     555-5656 

     6

     Mike Diamond

     555-6767 

    6 rows in set (0.01 sec)

    The fields we select can be in any order.

    mysql> SELECT name, phone, player_id FROM musicians;

     name

     phone

     player_id

     Roger Waters

     555-1212 

     1

     Geddy Lee

     555-2323 

     2

     Marshall Mathers III

     555-3434 

     3

     Thom Yorke

     555-4545 

     4

     Lenny Kravitz

     555-5656 

     5

     Mike Diamond

     555-6767 

     6

    6 rows in set (0.00 sec)

    We can request specific fields—we don’t need to show all the fields available.

    mysql> SELECT name, phone FROM musicians;
    +----------------------+----------+
    | name                 | phone    |
    +----------------------+----------+
    | Roger Waters         | 555-1212 |
    | Geddy Lee            | 555-2323 |
    | Marshall Mathers III | 555-3434 |
    | Thom Yorke           | 555-4545 |
    | Lenny Kravitz        | 555-5656 |
    | Mike Diamond         | 555-6767 |
    +----------------------+----------+
    6 rows in set (0.00 sec)

    Please check back next week for the continuation of this article.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This article is an excerpt from the book "Beginning Perl," published by Apress. We...
     

    Buy this book now. This article is excerpted from chapter 15 of the book Beginning Perl by James Lee (Apress; ISBN: 159059391X). Check it out today at your favorite bookstore. Buy this book now.

       

    PERL ARTICLES

    - Perl: Another Round with Hashes
    - Perl Hashes
    - Perl Lists: A Final Look at List::Util
    - Perl Lists: Utilizing List::Util
    - Perl Lists: The Split() Function
    - SQL and CGI with Perl and DBI
    - Perl Lists: More Functions and Operators
    - SELECT Queries and Perl
    - Perl Lists: More on Manipulation
    - Creating a Database with Perl and DBI
    - Perl: Sailing the List(less) Seas
    - Perl and DBI
    - Perl: Concatenating Text and More
    - Perl Text: Quoting Without Quote Marks
    - Perl: Releasing Your Inner Textuality




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