Results 1 to 5 of 5

Thread: Default constraint in database

  1. #1
    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..

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    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.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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'
    )

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    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.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    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

Similar Threads

  1. Replies: 3
    Last Post: 12-05-2012, 06:23 PM
  2. Task Start Date does not match constraint
    By ctslaton in forum Microsoft Project
    Replies: 2
    Last Post: 17-09-2011, 04:57 AM
  3. Vista - default printer doesn't stay as default
    By Freddie Kang in forum Vista Help
    Replies: 8
    Last Post: 19-04-2010, 03:12 AM
  4. Creating Database link in database
    By Lachlann in forum Software Development
    Replies: 3
    Last Post: 28-01-2010, 01:17 PM
  5. convert filemaker pro database to access database
    By Czack in forum MS Office Support
    Replies: 3
    Last Post: 15-04-2007, 01:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,012,012.23007 seconds with 16 queries