Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , ,

Sponsored Links



Default constraint in database

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 10-02-2010
Member
 
Join Date: Nov 2009
Posts: 43
Default constraint in database

Hello sir,
I am creating a table and need to specify a column as a TRUE or FALSE values but Unable to find any concept regrading this.I tried it from book also.I need to know in detailed about this.I am excited to implement it and need your help.

Thanks..
Reply With Quote
  #2  
Old 10-02-2010
Praetor's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,937
Default constraint in database

Default constraint :

The default constraint is very useful constraint to insert the default value into the column but there is no any concept of Boolean values in the database.It is applied for the database parameter which is performed by DBMS itself.

You can implement the Boolean values according to your way with the help of Default constraint.
Reply With Quote
  #3  
Old 10-02-2010
Member
 
Join Date: May 2008
Posts: 1,990
Specifying Default constraint in database

Specifying Default constraint :

You can specify the default constraint for table column after and before creation of the table.Add the Default option with column during creation and using alter command you can add it later.

This is the syntax to implement the default constraint for a database :

Code:
CREATE TABLE Persons
(
Id int NOT NULL,
Name varchar(255) NOT NULL,
City varchar(255),
Sex DEFAULT 'M'
)
Reply With Quote
  #4  
Old 10-02-2010
kelfro's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,976
DEFAULT Constraint on ALTER TABLE

DEFAULT Constraint on ALTER TABLE:

You can ALTER the table of database and implement the DEFAULT constraint.To do this you need to alter table first and then column with the combined statement.Use this statement to perform this task :

Code:
ALTER TABLE Persons
ALTER COLUMN City SET DEFAULT 'Washington';
The given example shows that a constraint has been added with City column and the values "Washington" would be inserted automatically when you skip the column to insert.
Reply With Quote
  #5  
Old 10-02-2010
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,267
DROP a DEFAULT Constraint

Dropping the DEFAULT Constraint :

You can drop the default constraint after implementing.The column would be free from any restriction of constraint.Use following SQL statement to drop it :

Code:
ALTER TABLE Persons
ALTER COLUMN City DROP DEFAULT
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Default constraint in database"
Thread Thread Starter Forum Replies Last Post
Task Start Date does not match constraint ctslaton Microsoft Project 2 17-09-2011 05:57 AM
Vista - default printer doesn't stay as default Freddie Kang Vista Help 8 19-04-2010 04:12 AM
Schema modification: relaxing constraint from single-valued to multi-valued. Chuck Chopp Active Directory 1 20-01-2010 03:54 PM
convert filemaker pro database to access database Albert Bricker MS Office Support 4 13-11-2009 12:32 AM
ADAM groupofnames constraint violation jag9750 Active Directory 3 23-04-2009 02:38 AM


All times are GMT +5.5. The time now is 11:07 AM.