Create table 订单
(
    订单ID int primary key not null,
    业务员ID int,
    订购日期 DateTime,
    发货日期 DateTime,
    运货费 Money check(运货费>0),
    货主名称 varchar(10),
 check(订购日期<发货日期)
)

解决方案 »

  1.   

    真快啊, 谢谢了
    能否给我解释下, 为什么要把"check(订购日期<发货日期)"放到最底下呢?
      

  2.   

    自己看看create table的语法。
      

  3.   

    我看了下语法, 对范式那里有点头晕了, 我觉得可以放在上面啊!你看下范式:CREATE TABLE
        [ database_name.[ owner ] .| owner.] table_name
        ( { < column_definition >
            | column_name AS computed_column_expression
            | < table_constraint > ::= [ CONSTRAINT constraint_name ] }            | [ { PRIMARY KEY | UNIQUE } [ ,...n ]
        ) 
    < table_constraint > ::= [ CONSTRAINT constraint_name ]
        { [ { PRIMARY KEY | UNIQUE }
            [ CLUSTERED | NONCLUSTERED ]
            { ( column [ ASC | DESC ] [ ,...n ] ) }
            [ WITH FILLFACTOR = fillfactor ]
            [ ON { filegroup | DEFAULT } ]
        ] 
        | FOREIGN KEY
            [ ( column [ ,...n ] ) ]
            REFERENCES ref_table [ ( ref_column [ ,...n ] ) ]
            [ ON DELETE { CASCADE | NO ACTION } ]
            [ ON UPDATE { CASCADE | NO ACTION } ]
            [ NOT FOR REPLICATION ]
        | CHECK [ NOT FOR REPLICATION ]
            ( search_conditions ) 
        }