Database Articles
  Home arrow Database Articles arrow Page 4 - Databases and SQL
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
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? 
DATABASE ARTICLES

Databases and SQL
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2004-04-19

    Table of Contents:
  • Databases and SQL
  • Adding Information To A Database
  • Retrieving Information From A Database
  • Changing Information In A Database
  • Conclusion

  • 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


    Databases and SQL - Changing Information In A Database


    (Page 4 of 5 )

    Occasionally data that is stored in a database may become stale. SQL's DELETE, UPDATE and DROP commands allow you to manage records and keep the information current.

    Delete

    The DELETE command is used to remove records from a table. Issue the DELETE command followed by FROM, the table that holds the records, WHERE and a condition statement that will be used to match the records.

    DELETE from addresses where first_name = "Harold"
    AND last_name = "Smith";

    The example query would remove Harold Smith's record from the addresses table.

    Update

    The UPDATE command can be used to update a record's fields. Issue the UPDATE command followed by the table name, SET, the field names and their new values, WHERE and a condition statement that will be used to match the correct record.

    For example, assume Gwendolyn Adams from our previous examples has decided to move to Milwaukee, WI. Her record in the database needs to be updated to reflect her new address.

    UPDATE addresses SET address = "613 Wright St.",
    city = "Milwaukee", state = "WI", zip_code="53216"
    WHERE (first_name = "Gwendolyn" AND last_name = "Adams");

    The query would update the record in the addresses table for Ms. Adams to store her new address of 613 Write St. Milwaukee, WI, 53216.

    Drop

    When data is no longer needed, the DROP command can be used to delete a table or an entire database. To delete a table, issue the DROP command, followed by TABLE and the name of the table to be dropped.

    DROP TABLE addresses;

    To delete an entire database, issue the DROP command, followed by DATABASE and the name of the database to be dropped.

    DROP DATABASE myDatabase;

    Be careful! Deleting entire tables and databases cannot be undone so one should be extremely cautious when using the DROP command.

    More Database Articles Articles
    More By bluephoenix


       · Hi,how can i make severals updates at the same time (nmaybe using while)i...
       · Like most other queries, UPDATE affects all of a table's rows unless you specify...
       · Please, can you help me. I'm very new beginer in php :)There's my problem. I know...
     

    DATABASE ARTICLES ARTICLES

    - More on Query Optimization for Oracle Databa...
    - Query Optimization in Oracle
    - Clusters and Other Data Structures for Oracle
    - Using Indexes with an Oracle Database
    - The Basics of Data Structures in Oracle
    - Oracle Data Structures
    - Best Practices for PL/SQL Variables
    - What`s Code Without Variables?
    - Clauses, Sorting, and SQL Queries
    - The From Clause and SQL Queries
    - Query Primer
    - Full Text Searches and Strings
    - Searching with Strings
    - Pattern Matching with Strings
    - Working with Cases of Strings





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek