SQL Question - Constraint

Daniel333Daniel333 Member Posts: 2,077 ■■■■■■□□□□
All,

Hi, been a few weeks since I even thought about SQL. It's been slow at work so they wanted me to put some time in studying. (woohoo!) Anyhow, I am learning what a constraint is.

e.g.
RATING CHAR(1) CHECK (RATING IN (A, B,C,D)

I was hoping someone could explain to me, why we have to refer to RATING twice? Is there any logic to this? Would you ever check a constraint against another field than the one the executed the constraint?

thanks,
-Daniel

Comments

  • BeaverC32BeaverC32 Member Posts: 670 ■■■□□□□□□□
    RATING CHAR(1) specifies that there is a column named RATING, and the data type is a CHAR

    CHECK specifies there is a constraint, and the parameters of that constraint are within the ().

    RATING IN states that the column RATING must have a value of A, B, C, or D
    MCSE 2003, MCSA 2003, LPIC-1, MCP, MCTS: Vista Config, MCTS: SQL Server 2005, CCNA, A+, Network+, Server+, Security+, Linux+, BSCS (Information Systems)
Sign In or Register to comment.