VisualBuilder
  Home > Database > Tutorials > Structure Modification,Updation and Deletion - SQL tutorial
Tell a friend
Link to us
Total Members
      Members: 84648
     
Sitemap Forum Chat
Home
SQL Tutorial Tutorial Home
1 . History of SQL
2 . SQL Components: An Overview
3 . Data Types in SQL
4 . Planning a Database: An Example: -
5 . Creating Tables
6 . Inserting Data using Insert
7 . Getting Data with Select Statement
8 . Working with Operators
9 . Selecting Unique rows with Distinct
10 . Arraging Data with Order by
11 . Working with Strings
12 . SQL AND
13 . Basic SQL Funtion
14 . Sub-Queries, Nested Queries
15 . Constraints in the Table
16 . SQL UPDATE
17 . View
18 . Relationships in a RDBMS
19 . Structure Modification,Updation and Deletion
 
Database Group Home
Database Discussion
Database Members (506)
Database Resources
Database Source Code (0)
Database Articles (0)
Database Blogs
Database Jobs
Database Components (0)
Database Books
Database Websites (0)
Database News (0)
Database Q & A (14)
- Database Ask Question
- Database Questions
- Database Unanswered Questions
 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.NET Development Tips
ASP.Net Security,Internationalisation And Deployment
ASP.NET Server Controls Tips
ASP.NET Tutorial
C Sharp Tutorial
LINQ
Web Development
Flex Tutorial
HTML Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Grails Tutorial
Hibernate Tutorial
Java 1.6 Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Service-Oriented Architecture (SOA) Tutorial For Managers
Spring Tutorial
Struts Tutorial

RESOURCES
Q & A (436 )
Source Code (3275 )
Articles (11 )
Components (1589 )
News (888 )
Websites (1207 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Link To Us
Feedback
Tell a Friend
Partners
Advertise


Database sql Tutorial
 Structure Modification,Updation and Deletion
  << Prev: Relationships in a RDBMS

It is possible to modify the structure of a table (the relation schema) even if rows have already been inserted into the table.


Adding the Column to the Table: - A column can be added using the alter table command. Following is the syntax for adding the column to the table.


Syntax: - alter table <table name> add(<column> data type [<default value>] [<column constraint>]);


If more than one column should be added at one time, respective add clauses need to be separated by colons.


A table constraint can be added to a table using


alter table <table name> add (<table constraint>);


(Note that a column constraint is a table constraint, too. not null and primary key constraints can only be added to a table if none of the specified columns contains a null value.)


Example: - Suppose you want to add a new column Contact_Number to the Student table in the previous example.


You can add the column using the following statement: -


alter table Student add(Contact_Number Number(10));


Modifying the Column of the Table: - A column can be modified using the alter table command. Following is the command for modifying the column attributes: -


Syntax: - alter table <table name> modify(<column> [<data type>] [<default value>] [<column constraint>]);


Example: - If you want to change the size of TeacherName in the Teacher table. You can do it with the following statement:-


alter table Teacher modify(TeacherName varchar2(35));


Deleting a Table: - A table and its rows can be deleted by issuing the drop table command. Following is the syntax for deleting a table.


Syntax: - drop table table name [cascade constraints];


Example: - If you want to delete the Marks table. You can delete it using the following statement:-


drop table Marks;


Updating the Table: - For modifying attribute values of (some) tuples in a table, we use the update statement. The following is the syntax for Update:


Syntax: - update <table name> set <column i> = <expression i>, . . . , <column j> = <expression j> [where <condition>];


An expression consists of either a constant (new value), an arithmetic or string operation, or an SQL query. Note that the new value to assign to column i must be the matching data type. An update statement without a where clause results in changing respective attributes of all tuples in the specified table. Typically, however, only a (small) portion of the table requires an update.


 


  << Prev: Relationships in a RDBMS
Database Sql Tutorial Home
Give feedback and win a prize.

 
   Printer Friendly
   Email to a friend
   Add to my Favourites    
  Download PDF version
   Report Bad Submissions
   Submit Feedback
 
  Delicious   Digg   Technorati   Blink   Furl   Reddit   Newsvine   Google Click each image to add
this page to each site.
 
 
Welcome Guest Signup
MEMBER'S PANEL
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!
 
SEARCH
 
 
LINKS
conferencing audio
Skype vs. sipcall
Gift to Pakistan
 
ADVERTISEMENT
 
PARTNER LIST

More
 
 
 

Home | Login | About Us | Contact Us | Privacy Policy | Advertising