这样加约束。ALTER TABLE [dbo].[publishers] WITH NOCHECK ADD 
CONSTRAINT [DF__publisher__count__7D78A4E7] DEFAULT ('USA') FOR [country],
 CHECK ([pub_id] = '1756' or ([pub_id] = '1622' or ([pub_id] = '0877' or ([pub_id] = '0736' or [pub_id] = '1389'))) or [pub_id] like '99[0-9][0-9]')
GO

解决方案 »

  1.   

    create table jobs
    (   job_id smallint IDENTITY(1,1)  PRIMARY KEY CLUSTERED,
        job_desc varchar(50) not null  default 'new position - title not formalized yet',
        min_lvl tinyint not null  check (min_lvl>=10),
        max_lvl tinyint not null  check (max_lvl <=250)
    )create table publishers
    (
      pub_id char(4) not null  constraint UPKCL_pubind primary key clustered check (pub_id in('1389',
                '0736','0877','1622','1756')  or pub_id like '99[0-9][0-9]'),
      pub_name  varchar(40)  null,
      city  varchar(20) null,
      state char(2)  null,
      country varchar(30)  null  default ('usa')
    )create table employee
    (
      emp_id int,
      fnme varchar(20) not null,
      minit char(1)  null,
      lname  varchar(30)  not null,
      job_id  smallint  not null default 1 references jobs(job_id),
      job_lvl tinyint default 10,
      pub_id char(4) not null  default ('9952') references publishers(pub_id),
      hire_date datetime not null  default (getdate())
    )
      

  2.   

    check (pub_id in('1389',
                '0736','0877','1622','1756')  or publid like '99[0-9][0-9]'),其中“publid”改为“pub_id”再试一试
      

  3.   

    我已经帮你改好了,
    1. create table publishers 放在create table employee前面.
    2.  publid”改为 pub_id我这里运行没有问题.
      

  4.   

    create  table jobs
    (   job_id smallint IDENTITY(1,1)  PRIMARY KEY CLUSTERED,
        job_desc varchar(50) not null  default 'new position - title not formalized yet',
        min_lvl tinyint not null  check (min_lvl>=10),
        max_lvl tinyint not null  check (max_lvl <=250)
    )
    create  table publishers
    (
      pub_id char(4) not null  constraint UPKCL_pubind primary key clustered check (pub_id in('1389',
                '0736','0877','1622','1756')  or pub_id like '99[0-9][0-9]'),
      pub_name  varchar(40)  null,
      city  varchar(20) null,
      state char(2)  null,
      country varchar(30)  null  default ('usa')
    )create  table employee
    (
      emp_id int,
      fnme varchar(20) not null,
      minit char(1)  null,
      lname  varchar(30)  not null,
      job_id  smallint  not null default 1 references jobs(job_id),
      job_lvl tinyint default 10,
      pub_id char(4) not null  default ('9952') references publishers(pub_id),
      hire_date datetime not null  default (getdate())
    )