Results 1 to 4 of 4

Thread: SQL constraints in Database

  1. #1
    Join Date
    Jan 2010
    Posts
    63

    SQL constraints in Database

    I am looking into setting up the constraints with an sql query instead of visually in programs.when I am going to insert some data in table and need to investigate that particular data is valid for table or not ? So how would I do that.If I am inserting some character and willing to show it into particular format,it can be done and how.Can you introduce me about different constraint in Structure Query Language.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    SQL constraints in Database

    The constraint is like a method in sql which works as a filter ,Every insert,update and delete data is filtered here when it need to send for operation.

    The Constraint can be specified after and before creation of table. Before creation of table,the statement takes the form like this "Create table.." and after creation "Alter table ...".

    The different types of constraint are as follows:
    * NOT NULL
    * UNIQUE
    * PRIMARY KEY
    * FOREIGN KEY
    * CHECK
    * DEFAULT

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    NOT NULL constraint in SQL

    NOT NULL:

    A NOT NULL constraint is a type of constraint which enforces the user to enter the value in the particular column for which NOT NULL constraint is specified.

    CREATE TABLE Family
    (
    Mem_Id int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int(4)
    )

    In the given example Mem_id and LastName is declared with the NOT NULL constraint,both columns are mandatory to enter the value.
    Last edited by MindSpace; 28-01-2010 at 09:12 AM.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Unique constraints in Database

    Unique constraint :

    The unique constraint uniquely identifies the every tuple in the table. It automatically created when we create the primary key for a table and primary key is also a database constraint.

    The declaration of Unique constraint would be as follows :

    CREATE TABLE Family
    (
    Mem_Id int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int(4),
    CONSTRAINT uc_Member_ID UNIQUE (Mem_Id,LastName)
    )

    In the above example the "uc_Member_ID" is the name of constraint and the values of Mem_id and LastName will be unique in the whole table.

Similar Threads

  1. SpringLayout.Constraints class
    By Prashobh Mallu in forum Software Development
    Replies: 5
    Last Post: 11-02-2010, 09:35 AM
  2. Creating Database link in database
    By Lachlann in forum Software Development
    Replies: 3
    Last Post: 28-01-2010, 01:17 PM
  3. Concept of the Constraints in SQL
    By Smita.bendal in forum Software Development
    Replies: 4
    Last Post: 30-11-2009, 11:25 AM
  4. Advise for constraints and combining projects
    By IreneL in forum Microsoft Project
    Replies: 2
    Last Post: 07-11-2008, 10:26 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,711,631,265.65903 seconds with 16 queries