About Clik  | abdi_issa@hotmail.com
Search
Home Somali Internet Software Downloads Education Books Join
HTML JavaScript VBScript SQL PL/SQL ASP Java C++
&nsbp; Click here to buy & sell on eBay!  Accept credit cards Now!
SQL Basics
Introduction
Create Tables
Data Types
Delete/Modify Tables
Adding new rows
Create Sequences
Retreive Data [Query]
Sub Queries
Single-Row Functions
Group Functions
Formating Data
Joining Multiple Tables
Creating View
 

Delete or Modify Table

ALTER TABLE  statement will allow you to add  new column or constraint, modify existing column or constraint, and drop existing column or existing constraint after the table is created.  The following statement will add a middle name column to the employees table.
ALTER TABLE employees
     ADD middle_name VARCHAR2(25);

 

The statement bellow modifies the last_name to required column. This statement works when there no null last name exist now.
ALTER TABLE employees
     MODIFY last_name NOT NULL;

This statement deletes the above column.
ALTER TABLE employees
     DROP last_name;

Adding, and deleting constraints are similar to those of the column.  Here is an statement to add a foreign key to employees table.
ALTER TABLE employees
     ADD FOREIGN KEY (department_id) NUMBER REFERENCES department;

To delete a column or constraint use DROP followed by the column or constraint name in the position of ADD or MODIFY.
Constraints can be turned off temporarily instead of dropping it, by using DISABLE/ENABLE clause within the alter table statement.  The bellow statement turns off the primary key for employees table.  ENABLE is used when turning it on.
 ALTER TABLE employees DISABLE PRIMARY KEY;

Data Types Insert Rows