Free Newsletters:
DatabaseDaily  
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed


follow us on Twitter





Brocade Doubles Down on 16 Gbps Fibre Channel

Microsoft Wants iOS Apps to Run on WP7

Avaya Debuts New Virtual Services Switch
Database Journal |DBA Support |SQLCourse |SQLCourse2







Technical Specialist – Pre-sales (MA)
Next Step Systems
US-MA-Littleton

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

SQL etc

August 16, 1998

Introduction to Databases for the Web: Pt. 1 - Page 11

By Selena Sol

Deleting Databases and Tables

It is also simple to delete tables and databases using GUI tools or SQL. In the case of a GUI, you will simply select a table or database from your main menu and delete it as you would a file in a file system manager.

In SQL, you would simply use the DELETE or DROP commands depending on if you were deleting a whole database or just a table in a single database.

In the case of deleting a whole database, you will use the DELETE command as follows:

DELETE DATABASE DATABASE_NAME;

The following example would delete the database MY_COMPANY:

DELETE DATABASE MY_COMPANY;

In the case of a table, you use the DROP command:

DROP TABLE TABLE_NAME;

such as:

DROP TABLE EMPLOYEES;

Essentially when you use delete and drop, you are modifying the database management system's data dictionary. It shouldn't have to be said, but I will say it...BE CAREFUL WHEN DELETING OR DROPPING!

Altering a Table

Finally, you should know that it is possible to "alter" a table after it has been created using either a standard GUI tool or by using the ALTER SQL command as follows:

ALTER TABLE  TABLE_NAME
      DROP   COLUMN_NAME, COLUMN_NAME
      ADD    COLUMN_NAME DATA_TYPE, COLUMN_NAME DATA_TYPE
      RENAME COLUMN_NAME NEW NAME
      MODIFY COLUMN_NAME DATA_TYPE;

such as the following case in which we alter the table named EMPLOYEES by dropping the E_GENDER Column and adding an E_ZIP column which will accept INTEGERS and which must be filled in for every new employee added to the table, and the E_MIDDLE_INIT column which will accept a single character as a value.

ALTER TABLE EMPLOYEES 
      DROP  E_GENDER
      ADD   E_ZIP INTEGER NOT NULL, 
            E_MIDDLE_INIT CHAR (1);

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

SQL etc Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 



Latest Forum Threads
SQL etc Forum
Topic By Replies Updated
get records within same group and with condition jutiyi 3 January 12th, 03:07 PM
Database SQL help needed to check date range clashes! deadlydragon121 7 January 9th, 02:47 PM
Remove Alpha from data in Column disk244 0 November 19th, 11:13 AM
sql query releatıon record show and sub total and grand total thank you for your howerlover 0 November 18th, 01:55 AM